Update web-platform-tests to revision 2b7dace05fc1869398ee24f84fda4c0e4c0455ae

This commit is contained in:
WPT Sync Bot 2018-08-31 21:37:12 +00:00 committed by Tom Servo
parent b23125d590
commit 6c901de216
844 changed files with 19802 additions and 3093 deletions

View file

@ -1,5 +0,0 @@
<!doctype html>
010-2
<script>
onload = function() {history.back()}
</script>

View file

@ -1,22 +0,0 @@
<!doctype html>
<title>Salvagability of document.opened document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="010-1.html"></iframe>
<script>
var iframe;
var t = async_test();
onload = t.step_func(function() {
iframe = document.getElementsByTagName("iframe")[0];
assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
iframe.contentDocument.close();
iframe.contentWindow.setTimeout(t.step_func(function() {t.done();}), 500);
onload = null;
iframe.src = "010-2.html"
setTimeout(t.step_func(function() {assert_unreached()}), 1000)
})
</script>

View file

@ -0,0 +1,29 @@
// Historically, document.open() created an entry in the session history so
// that the original page could be seen by going back. Test that this behavior
// no longer occurs.
//
// This test uses window.open() for variety, as most other tests in this
// directory use document.open(). An <iframe> would probably work also. We can
// always add an <iframe>-based test later if it is deemed necessary.
const t = async_test("document.open should not add an entry to the session history");
const frameURL = new URL("resources/history-frame.html", document.URL).href;
let origLength;
window.onFrameLoaded = t.step_func(() => {
window.onFrameLoaded = t.unreached_func("onFrameLoaded should only be called once");
assert_equals(win.document.URL, frameURL);
assert_true(win.document.body.textContent.includes("Old"));
origLength = win.history.length;
});
window.onDocumentOpen = t.step_func_done(() => {
window.onDocumentOpen = t.unreached_func("onDocumentOpen should only be called once");
assert_equals(win.document.URL, frameURL);
assert_true(win.document.body.textContent.includes("New"));
assert_not_equals(origLength, undefined);
assert_equals(win.history.length, origLength);
});
const win = window.open(frameURL);
t.add_cleanup(() => win.close());

View file

@ -0,0 +1,74 @@
test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.contentDocument.close());
assert_equals(frame.contentDocument.compatMode, "BackCompat");
frame.contentDocument.open();
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.close();
assert_equals(frame.contentDocument.compatMode, "BackCompat");
}, "document.open() sets document to no-quirks mode (write no doctype)");
test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.contentDocument.close());
assert_equals(frame.contentDocument.compatMode, "BackCompat");
frame.contentDocument.open();
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.write("<!doctype html public");
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.write(" \"-//IETF//DTD HTML 3//\"");
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.write(">");
assert_equals(frame.contentDocument.compatMode, "BackCompat");
frame.contentDocument.close();
assert_equals(frame.contentDocument.compatMode, "BackCompat");
}, "document.open() sets document to no-quirks mode (write old doctype)");
test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.contentDocument.close());
assert_equals(frame.contentDocument.compatMode, "BackCompat");
frame.contentDocument.open();
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.write("<!doctype html");
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.write(">");
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
frame.contentDocument.close();
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
}, "document.open() sets document to no-quirks mode (write new doctype)");
// This tests the document.open() call in fact sets the document to no-quirks
// mode, not limited-quirks mode. It is derived from
// quirks/blocks-ignore-line-height.html in WPT, as there is no direct way to
// distinguish between a no-quirks document and a limited-quirks document. It
// assumes that the user agent passes the linked test, which at the time of
// writing is all major web browsers.
test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.contentDocument.close());
assert_equals(frame.contentDocument.compatMode, "BackCompat");
frame.contentDocument.open();
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
// Create the DOM tree manually rather than going through document.write() to
// bypass the parser, which resets the document mode.
const html = frame.contentDocument.appendChild(frame.contentDocument.createElement("html"));
const body = html.appendChild(frame.contentDocument.createElement("body"));
assert_equals(frame.contentDocument.body, body);
body.innerHTML = `
<style>#ref { display:block }</style>
<div id=test><font size=1>x</font></div>
<font id=ref size=1>x</font>
<div id=s_ref>x</div>
`;
assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
const idTest = frame.contentDocument.getElementById("test");
const idRef = frame.contentDocument.getElementById("ref");
const idSRef = frame.contentDocument.getElementById("s_ref");
assert_equals(frame.contentWindow.getComputedStyle(idTest).height,
frame.contentWindow.getComputedStyle(idSRef).height);
assert_not_equals(frame.contentWindow.getComputedStyle(idTest).height,
frame.contentWindow.getComputedStyle(idRef).height);
}, "document.open() sets document to no-quirks mode, not limited-quirks mode");

View file

@ -0,0 +1,25 @@
// This tests the behavior of dynamic markup insertion APIs with a document's
// readiness.
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => { frame.remove(); });
frame.src = "/common/blank.html";
frame.onload = t.step_func_done(() => {
const states = [];
frame.contentDocument.onreadystatechange = t.step_func(() => {
states.push(frame.contentDocument.readyState);
});
assert_equals(frame.contentDocument.readyState, "complete");
assert_array_equals(states, []);
// When open() is called, it first removes the event listeners and handlers
// from all nodes in the DOM tree. Then, after a new parser is created and
// initialized, it changes the current document readiness to "loading".
// However, because all event listeners are removed, we cannot observe the
// readystatechange event fired for "loading" inside open().
frame.contentDocument.open();
assert_equals(frame.contentDocument.readyState, "loading");
assert_array_equals(states, []);
});
}, "document.open() and readiness");

View file

@ -0,0 +1,20 @@
<script>
function queueTest() {
// The timeout is necessary to avoid the parser still being active when
// `document.open()` is called and becoming a no-op.
//
// We also cannot use setTimeout(..., 0), as the parser is terminated in a
// task with DOM manipulation task source while the timeout is run in a task
// on the timer task source. The order is therefore not guaranteed. Let's
// play it safer and use some actual timeout.
setTimeout(() => {
document.open();
document.write("<p>New content</p>");
document.close();
opener.onDocumentOpen();
}, 200);
}
</script>
<body onload="opener.onFrameLoaded(); queueTest();">
<p>Old content</p>
</body>

View file

@ -0,0 +1,9 @@
<script>
onload = () => {
const beforeURL = document.URL;
document.open();
const afterURL = document.URL;
document.close();
parent.testDone(beforeURL, afterURL);
}
</script>

View file

@ -0,0 +1,26 @@
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe")),
urlSansHash = document.URL;
t.add_cleanup(() => { frame.remove(); });
assert_equals(frame.contentDocument.URL, "about:blank");
assert_equals(frame.contentWindow.location.href, "about:blank");
self.onhashchange = t.step_func_done(() => {
frame.contentDocument.open();
assert_equals(frame.contentDocument.URL, urlSansHash);
assert_equals(frame.contentWindow.location.href, urlSansHash);
});
self.location.hash = "heya";
}, "document.open() and document's URL containing a fragment (entry is not relevant)");
window.testDone = undefined;
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"))
t.add_cleanup(() => { frame.remove(); });
frame.src = "resources/url-frame.html#heya";
window.testDone = t.step_func_done((beforeURL, afterURL) => {
assert_equals(beforeURL, frame.src);
assert_equals(afterURL, frame.src);
assert_equals(frame.contentDocument.URL, frame.src);
assert_equals(frame.contentWindow.location.href, frame.src);
});
}, "document.open() and document's URL containing a fragment (entry is relevant)");