mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 0f31ab1b094596062154092307bb9ff8e6122533
This commit is contained in:
parent
96ad6710b1
commit
372e03fe64
32 changed files with 992 additions and 222 deletions
|
@ -0,0 +1,49 @@
|
|||
'use strict';
|
||||
|
||||
function query_is_css_parseable(query) {
|
||||
const style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
document.head.appendChild(style);
|
||||
|
||||
const sheet = style.sheet;
|
||||
try {
|
||||
sheet.insertRule("@media " + query + "{}", 0);
|
||||
return sheet.cssRules.length == 1 &&
|
||||
sheet.cssRules[0].media.mediaText != "not all";
|
||||
} finally {
|
||||
while (sheet.cssRules.length)
|
||||
sheet.deleteRule(0);
|
||||
style.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function query_should_be_css_parseable(query) {
|
||||
test(() => {
|
||||
assert_true(query_is_css_parseable(query));
|
||||
}, "Should be parseable in a CSS stylesheet: '" + query + "'");
|
||||
}
|
||||
|
||||
function query_should_not_be_css_parseable(query) {
|
||||
test(() => {
|
||||
assert_false(query_is_css_parseable(query));
|
||||
}, "Should not be parseable in a CSS stylesheet: '" + query + "'");
|
||||
}
|
||||
|
||||
function query_is_js_parseable(query) {
|
||||
// We cannot rely on whether a given feature is on or off, so only check the
|
||||
// 'media' member of the result.
|
||||
const match = window.matchMedia(query);
|
||||
return match.media == query;
|
||||
}
|
||||
|
||||
function query_should_be_js_parseable(query) {
|
||||
test(() => {
|
||||
assert_true(query_is_js_parseable(query));
|
||||
}, "Should be parseable in JS: '" + query + "'");
|
||||
}
|
||||
|
||||
function query_should_not_be_js_parseable(query) {
|
||||
test(() => {
|
||||
assert_false(query_is_js_parseable(query));
|
||||
}, "Should not be parseable in JS: '" + query + "'");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue