зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1413754: Add tests for parsing of non-content-exposed media queries. r=xidorn
MozReview-Commit-ID: 4B8EPLboM4G --HG-- extra : rebase_source : 1731ca6931c0aa67df918cf576cd4a0dc868c2e1
This commit is contained in:
Родитель
2872402b2d
Коммит
9951add396
|
@ -15,6 +15,7 @@ support-files =
|
|||
[test_bug1157097.html]
|
||||
[test_bug1160724.xul]
|
||||
[test_bug535806.xul]
|
||||
[test_chrome_only_media_queries.html]
|
||||
[test_display_mode.html]
|
||||
tags = fullscreen
|
||||
[test_display_mode_reflow.html]
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
<!doctype html>
|
||||
<title>Test for parsing of non-content-exposed media-queries.</title>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<style></style>
|
||||
<script>
|
||||
const SHEET = document.querySelector('style');
|
||||
|
||||
function expect(q, shouldBeParseable) {
|
||||
const NOT_PARSEABLE_TEXT = "@media screen, not all {\n}";
|
||||
|
||||
let text = "@media screen, " + q + " {\n}";
|
||||
SHEET.textContent = text;
|
||||
|
||||
let rules = SHEET.sheet.cssRules;
|
||||
is(rules.length, 1, `Rule not parsed for ${q}`);
|
||||
is(rules[0].cssText,
|
||||
shouldBeParseable ? text : NOT_PARSEABLE_TEXT,
|
||||
`Serialization for ${q}`);
|
||||
}
|
||||
|
||||
function expectParseable(q) {
|
||||
expect(q, true);
|
||||
}
|
||||
|
||||
function expectNonParseable(q) {
|
||||
expect(q, false);
|
||||
}
|
||||
|
||||
// Test a toggle that should always match for `1` or `0`.
|
||||
function testToggle(toggle) {
|
||||
expectParseable(`(${toggle})`);
|
||||
expectParseable(`(${toggle}: 1)`);
|
||||
expectParseable(`(${toggle}: 0)`);
|
||||
|
||||
expectNonParseable(`(${toggle}: foo)`);
|
||||
expectNonParseable(`(min-${toggle}: 0)`);
|
||||
expectNonParseable(`(max-${toggle}: 0)`);
|
||||
expectNonParseable(`(max-${toggle})`);
|
||||
expectNonParseable(`(min-${toggle})`);
|
||||
|
||||
let matches_1 = matchMedia(`(${toggle}: 1)`).matches;
|
||||
let matches_0 = matchMedia(`(${toggle}: 0)`).matches;
|
||||
isnot(matches_0, matches_1, `Should not match both true and false: ${toggle}`);
|
||||
is(matches_0 || matches_1, true, `Should match at least one: ${toggle}`);
|
||||
}
|
||||
|
||||
const TOGGLES = [
|
||||
"-moz-is-glyph",
|
||||
"-moz-scrollbar-start-backward",
|
||||
"-moz-scrollbar-start-forward",
|
||||
"-moz-scrollbar-end-backward",
|
||||
"-moz-scrollbar-end-forward",
|
||||
"-moz-overlay-scrollbars",
|
||||
"-moz-windows-default-theme",
|
||||
"-moz-mac-graphite-theme",
|
||||
"-moz-mac-yosemite-theme",
|
||||
"-moz-windows-accent-color-in-titlebar",
|
||||
"-moz-windows-compositor",
|
||||
"-moz-windows-classic",
|
||||
"-moz-windows-glass",
|
||||
"-moz-swipe-animation-enabled",
|
||||
"-moz-touch-enabled",
|
||||
];
|
||||
|
||||
for (let i = 0; i < TOGGLES.length; ++i) {
|
||||
testToggle(TOGGLES[i])
|
||||
}
|
||||
|
||||
expectParseable("(-moz-windows-theme: aero)");
|
||||
expectParseable("(-moz-windows-theme: aero-lite)");
|
||||
expectParseable("(-moz-windows-theme: luna-blue)");
|
||||
expectParseable("(-moz-windows-theme: luna-olive)");
|
||||
expectParseable("(-moz-windows-theme: luna-silver)");
|
||||
expectParseable("(-moz-windows-theme: royale)");
|
||||
expectParseable("(-moz-windows-theme: generic)");
|
||||
expectParseable("(-moz-windows-theme: zune)");
|
||||
expectParseable("(-moz-windows-theme: garbage)");
|
||||
expectNonParseable("(-moz-windows-theme: '')");
|
||||
expectNonParseable("(-moz-windows-theme: )");
|
||||
|
||||
expectParseable("(-moz-os-version: windows-win7)");
|
||||
expectParseable("(-moz-os-version: windows-win8)");
|
||||
expectParseable("(-moz-os-version: windows-win10)");
|
||||
expectNonParseable("(-moz-os-version: )");
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче