Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326

This commit is contained in:
Josh Matthews 2017-10-12 09:25:50 -04:00
parent 462c272380
commit 1f531f66ea
5377 changed files with 174916 additions and 84369 deletions

View file

@ -1,5 +1,6 @@
<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<title>Parsing of meta refresh</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
@ -14,14 +15,14 @@ iframe { display:none }
var tests_arr = [
{input: '', expected: []},
{input: '1', expected: [1, 'refresh.sub.html']},
{input: '1 ', expected: [1, 'refresh.sub.html']},
{input: '1\t', expected: [1, 'refresh.sub.html']},
{input: '1\r', expected: [1, 'refresh.sub.html']},
{input: '1\n', expected: [1, 'refresh.sub.html']},
{input: '1\f', expected: [1, 'refresh.sub.html']},
{input: '1;', expected: [1, 'refresh.sub.html']},
{input: '1,', expected: [1, 'refresh.sub.html']},
{input: '1', expected: [1, '__filename__']},
{input: '1 ', expected: [1, '__filename__']},
{input: '1\t', expected: [1, '__filename__']},
{input: '1\r', expected: [1, '__filename__']},
{input: '1\n', expected: [1, '__filename__']},
{input: '1\f', expected: [1, '__filename__']},
{input: '1;', expected: [1, '__filename__']},
{input: '1,', expected: [1, '__filename__']},
{input: '1; url=foo', expected: [1, 'foo']},
{input: '1, url=foo', expected: [1, 'foo']},
{input: '1 url=foo', expected: [1, 'foo']},
@ -57,7 +58,9 @@ var tests_arr = [
{input: '1; ufoo', expected: [1, 'ufoo']},
{input: '1; "foo"bar', expected: [1, 'foo']},
{input: '; foo', expected: []},
{input: ';foo', expected: []},
{input: ', foo', expected: []},
{input: ',foo', expected: []},
{input: 'foo', expected: []},
{input: '+1; url=foo', expected: []},
{input: '-1; url=foo', expected: []},
@ -73,40 +76,57 @@ var tests_arr = [
{input: '-1', expected: []},
{input: '+0', expected: []},
{input: '-0', expected: []},
{input: '0', expected: [0, 'refresh.sub.html']},
{input: '0', expected: [0, '__filename__']},
{input: '1.9; url=foo', expected: [1, 'foo']},
{input: '1.9..5.; url=foo', expected: [1, 'foo']},
{input: '.9; url=foo', expected: []},
{input: '.9; url=foo', expected: [0, 'foo']},
{input: '0.9; url=foo', expected: [0, 'foo']},
{input: '0...9; url=foo', expected: [0, 'foo']},
{input: '0...; url=foo', expected: [0, 'foo']},
{input: '1e0; url=foo', expected: []},
{input: '1e1; url=foo', expected: []},
{input: '10e-1; url=foo', expected: []},
{input: '-0.1; url=foo', expected: []},
];
tests_arr.forEach(function(test_obj) {
async_test(function(t) {
var iframe = document.createElement('iframe');
t.add_cleanup(function() {
document.body.removeChild(iframe);
});
iframe.src = 'support/refresh.sub.html?input=' + encodeURIComponent(test_obj.input);
document.body.appendChild(iframe);
var loadCount = 0;
iframe.onload = t.step_func(function() {
loadCount++;
var got = iframe.contentDocument.body.textContent.trim();
if (test_obj.expected.length === 0) {
assert_equals(got, 'refresh.sub.html');
if (loadCount === 1) {
setTimeout(function() {
t.done();
}, 3000); // want to make sure it doesn't redirect when it shouldn't
["<meta>", "Refresh header"].forEach(type => {
if(type === "Refresh header" && test_obj.input.match("[\n\r\f]")) { // See https://github.com/w3c/wptserve/issues/111 for why \f as well
return;
}
const filename = type === "<meta>" ? "refresh.sub.html" : "refresh.py";
async_test(function(t) {
var iframe = document.createElement('iframe');
t.add_cleanup(function() {
document.body.removeChild(iframe);
});
iframe.src = "support/" + filename + "?input=" + encodeURIComponent(test_obj.input);
document.body.appendChild(iframe);
var loadCount = 0;
iframe.onload = t.step_func(function() {
loadCount++;
var got = iframe.contentDocument.body.textContent.trim();
if (test_obj.expected.length === 0) {
assert_equals(got, filename);
if (loadCount === 1) {
t.step_timeout(function() {
t.done();
}, 3000); // want to make sure it doesn't redirect when it shouldn't
} else {
assert_unreached('Got > 1 load events');
}
} else {
assert_unreached('Got > 1 load events');
if (loadCount === 2) {
if(test_obj.expected[1] === "__filename__") {
assert_equals(got, filename);
} else {
assert_equals(got, test_obj.expected[1]);
}
t.done();
}
}
} else {
if (loadCount === 2) {
assert_equals(got, test_obj.expected[1]);
t.done();
}
}
});
}, format_value(test_obj.input));
});
}, type + ": " + format_value(test_obj.input));
});
});
</script>

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>When moving between documents, must refresh the original document</title>
<title>A meta must refresh the original document even if it was removed.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh">
@ -11,9 +11,7 @@
"use strict";
const sourceIFrame = document.createElement("iframe");
const destIFrame = document.createElement("iframe");
let sourceLoadCount = 0;
let destLoadCount = 0;
sourceIFrame.onload = () => {
++sourceLoadCount;
@ -26,26 +24,13 @@ sourceIFrame.onload = () => {
maybeStartTest();
};
destIFrame.onload = () => {
++destLoadCount;
if (destLoadCount === 2) {
assert_unreached("The iframe into which the meta was moved must not refresh");
}
maybeStartTest();
};
function maybeStartTest() {
if (sourceLoadCount === 1 && destLoadCount === 1) {
const meta = sourceIFrame.contentDocument.querySelector("meta");
destIFrame.contentDocument.body.appendChild(meta);
if (sourceLoadCount === 1) {
sourceIFrame.contentDocument.querySelector("meta").remove();
}
}
sourceIFrame.src = "support/refresh.sub.html?input=" + encodeURIComponent("1; url=foo");
destIFrame.src = "support/ufoo";
document.body.appendChild(sourceIFrame);
document.body.appendChild(destIFrame);
</script>

View file

@ -0,0 +1,4 @@
def main(request, response):
response.headers.set("Content-Type", "text/html")
response.headers.set("Refresh", request.GET.first("input"))
response.content = "<!doctype html>refresh.py\n"

View file

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dynamically changing HTMLStyleElement.media should change the rendering accordingly</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element">
<style>
span {
color: red;
}
</style>
<style id="text-style" media="none">
span {
color: green;
}
</style>
<style id="body-style" media="aural">
body {
color: green;
}
</style>
</head>
<body>
<span>text</span>
<script>
test(function() {
var element = document.querySelector("span");
assert_equals(getComputedStyle(element).color, "rgb(255, 0, 0)");
document.getElementById("text-style").media = 'all';
assert_equals(getComputedStyle(element).color, "rgb(0, 128, 0)");
}, "change media value dynamically");
test(function() {
var style = document.getElementById("body-style");
assert_not_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
style.removeAttribute("media");
assert_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
}, "removing media attribute");
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Test: Non-matching media type should have stylesheet</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style media="unknown">
body { color: green }
</style>
</head>
<body>
<script>
test(function() {
assert_equals(document.styleSheets.length, 1);
});
</script>
</body>
</html>

View file

@ -0,0 +1,71 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>&lt;style> type="" edge cases</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#update-a-style-block">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#test1 { color: rgb(0, 128, 0); }
</style>
<style type="">
#test2 { color: rgb(0, 128, 0); }
</style>
<style type="TEXT/CsS">
#test3 { color: rgb(0, 128, 0); }
</style>
<style type=" text/css ">
#test4 { color: rgb(0, 128, 0); }
</style>
<style type="text/css; charset=utf-8">
#test5 { color: rgb(0, 128, 0); }
</style>
<body>
<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>
<div id="test4"></div>
<div id="test5"></div>
<script>
"use strict";
test(() => {
assertApplied("test1");
}, "With no type attribute, the style should apply");
test(() => {
assertApplied("test2");
}, "With an empty type attribute, the style should apply");
test(() => {
assertApplied("test3");
}, "With a mixed-case type attribute, the style should apply");
test(() => {
assertNotApplied("test4");
}, "With a whitespace-surrounded type attribute, the style should not apply");
test(() => {
assertNotApplied("test5");
}, "With a charset parameter in the type attribute, the style should not apply");
function getColor(id) {
return window.getComputedStyle(document.getElementById(id)).color;
}
function assertApplied(id) {
assert_equals(getColor(id), "rgb(0, 128, 0)");
}
function assertNotApplied(id) {
assert_not_equals(getColor(id), "rgb(0, 128, 0)");
}
</script>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dynamically changing HTMLStyleElement.type should change the rendering accordingly</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element">
<style type="no/mime">
body { color: green }
</style>
</head>
<body>
Text content.
<script>
var style = document.querySelector("style");
test(function() {
assert_equals(document.styleSheets.length, 0);
}, "Check initial styleSheets length type");
test(function() {
assert_not_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
assert_equals(document.styleSheets.length, 0);
style.type = "text/css";
assert_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
assert_equals(document.styleSheets.length, 1);
}, "Change type from invalid type to valid type");
test(function() {
assert_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
assert_equals(document.styleSheets.length, 1);
style.type = "no/mime";
assert_not_equals(getComputedStyle(document.querySelector("body")).color, "rgb(0, 128, 0)");
assert_equals(document.styleSheets.length, 0);
}, "Change type from valid type to invalid type");
</script>
</body>
</html>