mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 6c2d23b1b5e4dc00c944eedd16a11850e74a2d11
This commit is contained in:
parent
ad83faa745
commit
0114122fe0
140 changed files with 4328 additions and 1419 deletions
|
@ -1,20 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>Replacement of window object after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
iframe.contentWindow.state = 1;
|
||||
var handle = iframe.contentWindow;
|
||||
iframe.contentDocument.open();
|
||||
assert_false("state" in iframe.contentWindow, "Variables are not preserved after document.open");
|
||||
assert_equals(iframe.contentWindow.state, undefined, "Variables are not preserved after document.open");
|
||||
assert_equals(iframe.contentWindow, handle);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -1,20 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>Replacement of document prototype object after document.open</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="/common/blank.html"></iframe>
|
||||
<script>
|
||||
var t = async_test();
|
||||
var iframe;
|
||||
onload = t.step_func(function() {
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
var handle = Object.getPrototypeOf(iframe.contentDocument);
|
||||
handle.test_state = 1;
|
||||
assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
|
||||
var new_handle = Object.getPrototypeOf(iframe.contentDocument);
|
||||
assert_equals(new_handle.test_state, undefined);
|
||||
assert_not_equals(new_handle, handle);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -1,34 +0,0 @@
|
|||
<!doctype html>
|
||||
<title>document.open replacing singleton</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="/common/blank.html"></iframe>
|
||||
<script>
|
||||
var iframe = document.getElementsByTagName("iframe")[0];
|
||||
var steps;
|
||||
iframe.onload = function() {
|
||||
steps = ["window", "location", "history", "navigator", "applicationCache", "sessionStorage", "localStorage", "locationbar"].map(
|
||||
function(x) {
|
||||
var t = async_test(document.title + " " + x);
|
||||
var handle = iframe.contentWindow[x];
|
||||
handle.test_state = 1;
|
||||
return t.step_func(
|
||||
function() {
|
||||
var new_handle = iframe.contentWindow[x];
|
||||
assert_equals(new_handle.test_state, undefined);
|
||||
if (x !== "window") {
|
||||
assert_not_equals(new_handle, handle);
|
||||
} else {
|
||||
assert_equals(new_handle, handle);
|
||||
}
|
||||
t.done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
onload = function() {
|
||||
assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
|
||||
steps.forEach(function(x) {x()});
|
||||
}
|
||||
</script>
|
|
@ -5,7 +5,7 @@ onload = function() {
|
|||
parent.tests[0].step(function() {parent.assert_equals(document.open(), document)});
|
||||
document.write("<script>test_prop = 2;<\/script>");
|
||||
document.close();
|
||||
parent.tests[0].step(function() {parent.assert_equals(test_prop, 1)});
|
||||
parent.tests[0].step(function() {parent.assert_equals(test_prop, 2)});
|
||||
parent.tests[1].step(function() {parent.assert_equals(window.test_prop, 2)});
|
||||
parent.tests[2].step(function() {parent.assert_equals(get_this(), window)});
|
||||
parent.tests_done();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div id="log"></div>
|
||||
<script>
|
||||
var tests = [async_test("global scope unchanged"),
|
||||
async_test("window object changed"),
|
||||
async_test("window object unchanged"),
|
||||
async_test("this is the window object")];
|
||||
function tests_done() {
|
||||
tests.forEach(function(t) {t.done()});
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// In an earlier version of the HTML Standard, document open steps had "prompt
|
||||
// to unload document" as a step. Test that this no longer happens.
|
||||
|
||||
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(() => {
|
||||
frame.contentWindow.onbeforeunload = t.unreached_func("beforeunload should not be fired");
|
||||
frame.contentDocument.open();
|
||||
t.step_timeout(t.step_func_done(() => {
|
||||
// If the beforeunload event has still not fired by this point, we
|
||||
// consider the test a success. `frame.remove()` above will allow the
|
||||
// `load` event to be fired on the top-level Window, thus unblocking
|
||||
// testharness.
|
||||
}), 500);
|
||||
});
|
||||
}, "document.open() should not fire a beforeunload event");
|
|
@ -3,7 +3,7 @@
|
|||
onload = function() {
|
||||
document.open();
|
||||
document.close();
|
||||
parent.report(window.setTimeout === setTimeout, false, "setTimeout");
|
||||
parent.report(window.setTimeout === setTimeout, true, "setTimeout");
|
||||
parent.report(window === this, true, "this");
|
||||
parent.done();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<title>document.open and singleton replacement</title>
|
||||
<title>document.open and no singleton replacement</title>
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-open">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
// In an earlier version of the HTML Standard, document open steps created a
|
||||
// new JavaScript realm and migrated the existing objects to use the new realm.
|
||||
// Test that this no longer happens.
|
||||
|
||||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
// Ensure a load event gets dispatched to unblock testharness
|
||||
t.add_cleanup(() => frame.remove());
|
||||
frame.src = "resources/global-variables-frame.html";
|
||||
frame.onload = t.step_func_done(() => {
|
||||
assert_equals(frame.contentWindow.hey, "You", "precondition");
|
||||
frame.contentDocument.open();
|
||||
assert_equals(frame.contentWindow.hey, "You", "actual check");
|
||||
});
|
||||
}, "Obtaining a variable from a global whose document had open() invoked");
|
||||
|
||||
function testIdentity(desc, frameToObject, frameToConstructor) {
|
||||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
// Ensure a load event gets dispatched to unblock testharness
|
||||
t.add_cleanup(() => frame.remove());
|
||||
frame.src = "/common/blank.html";
|
||||
frame.onload = t.step_func_done(() => {
|
||||
const obj = frameToObject(frame);
|
||||
frame.contentDocument.open();
|
||||
assert_equals(frameToObject(frame), obj);
|
||||
});
|
||||
}, `${desc} maintains object identity through open()`);
|
||||
|
||||
async_test(t => {
|
||||
const frame = document.body.appendChild(document.createElement("iframe"));
|
||||
// Ensure a load event gets dispatched to unblock testharness
|
||||
t.add_cleanup(() => frame.remove());
|
||||
frame.src = "/common/blank.html";
|
||||
frame.onload = t.step_func_done(() => {
|
||||
const obj = frameToObject(frame);
|
||||
const origProto = Object.getPrototypeOf(obj);
|
||||
const origCtor = frameToConstructor(frame);
|
||||
const sym = Symbol();
|
||||
obj[sym] = "foo";
|
||||
frame.contentDocument.open();
|
||||
assert_equals(frameToObject(frame)[sym], "foo");
|
||||
assert_true(frameToObject(frame) instanceof origCtor);
|
||||
assert_equals(Object.getPrototypeOf(frameToObject(frame)), origProto);
|
||||
assert_equals(frameToConstructor(frame), origCtor);
|
||||
});
|
||||
}, `${desc} maintains its prototype and properties through open()`);
|
||||
}
|
||||
|
||||
testIdentity("Document", frame => frame.contentDocument, frame => frame.contentWindow.Document);
|
||||
testIdentity("WindowProxy", frame => frame.contentWindow, frame => frame.contentWindow.Window);
|
||||
testIdentity("BarProp", frame => frame.contentWindow.locationbar, frame => frame.contentWindow.BarProp);
|
||||
testIdentity("History", frame => frame.contentWindow.history, frame => frame.contentWindow.History);
|
||||
testIdentity("localStorage", frame => frame.contentWindow.localStorage, frame => frame.contentWindow.Storage);
|
||||
testIdentity("Location", frame => frame.contentWindow.location, frame => frame.contentWindow.Location);
|
||||
testIdentity("sessionStorage", frame => frame.contentWindow.sessionStorage, frame => frame.contentWindow.Storage);
|
||||
testIdentity("Navigator", frame => frame.contentWindow.navigator, frame => frame.contentWindow.Navigator);
|
|
@ -0,0 +1,4 @@
|
|||
<!doctype html>
|
||||
<script>
|
||||
hey = "You";
|
||||
</script>
|
|
@ -0,0 +1,19 @@
|
|||
// In an earlier version of the HTML Standard, document open steps had "unload
|
||||
// document" as a step. Test that this no longer happens.
|
||||
|
||||
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(() => {
|
||||
frame.contentWindow.onpagehide = t.unreached_func("onpagehide got called");
|
||||
frame.contentDocument.onvisibilitychange = t.unreached_func("onvisibilitychange got called");
|
||||
frame.contentWindow.onunload = t.unreached_func("onunload got called");
|
||||
frame.contentDocument.open();
|
||||
t.step_timeout(t.step_func_done(() => {
|
||||
// If none of the three events have been fired by this point, we consider
|
||||
// the test a success. `frame.remove()` above will allow the `load` event
|
||||
// to be fired on the top-level Window, thus unblocking testharness.
|
||||
}), 500);
|
||||
});
|
||||
}, "document.open(): Do not fire pagehide, visibilitychange, or unload events");
|
Loading…
Add table
Add a link
Reference in a new issue