mirror of
https://github.com/servo/servo
synced 2026-05-05 06:32:13 +02:00
Update web-platform-tests to revision dc5cbf088edcdb266541d4e5a76149a2c6e716a0
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<meta name="timeout" content="long">
|
||||
<title>Cross-origin behavior of Window and Location on new Window</title>
|
||||
<link rel="author" title="Bobby Holley (:bholley)" href="bobbyholley@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#security-window">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#security-location">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
window.addEventListener('message', function onmessage(evt) {
|
||||
window.removeEventListener('message', onmessage);
|
||||
test(function() {
|
||||
var results = evt.data;
|
||||
assert_true(results.length > 0, 'Need results');
|
||||
results.forEach(function(r) { assert_true(r.pass, r.message); });
|
||||
}, "Cross-origin object identity preserved across document.domain");
|
||||
win.close();
|
||||
done();
|
||||
});
|
||||
var win = window.open('win-documentdomain.sub.html');
|
||||
</script>
|
||||
@@ -7,6 +7,7 @@
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#security-location">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<div id=log></div>
|
||||
<iframe id="B"></iframe>
|
||||
<iframe id="C"></iframe>
|
||||
@@ -16,13 +17,14 @@
|
||||
* Setup boilerplate. This gives us a same-origin window "B" and a cross-origin
|
||||
* window "C".
|
||||
*/
|
||||
var host_info = get_host_info();
|
||||
|
||||
setup({explicit_done: true});
|
||||
path = location.pathname.substring(0, location.pathname.lastIndexOf('/')) + '/frame.html';
|
||||
var B = document.getElementById('B').contentWindow;
|
||||
var C = document.getElementById('C').contentWindow;
|
||||
B.frameElement.uriToLoad = path;
|
||||
C.frameElement.uriToLoad = '//{{domains[www1]}}:' + location.port + path;
|
||||
C.frameElement.uriToLoad = get_host_info().HTTP_REMOTE_ORIGIN + path;
|
||||
|
||||
function reloadSubframes(cb) {
|
||||
var iframes = document.getElementsByTagName('iframe');
|
||||
@@ -51,7 +53,9 @@ function addTest(fun, desc) { testList.push([fun, desc]); }
|
||||
*/
|
||||
|
||||
addTest(function() {
|
||||
assert_equals(location.host, '{{domains[]}}:{{location[port]}}', 'Need to run the top-level test from {{domains[]}}:{{location[port]}}');
|
||||
// Note: we do not check location.host as its default port semantics are hard to reflect statically
|
||||
assert_equals(location.hostname, host_info.ORIGINAL_HOST, 'Need to run the top-level test from domain ' + host_info.ORIGINAL_HOST);
|
||||
assert_equals(location.port, host_info.HTTP_PORT, 'Need to run the top-level test from port ' + host_info.HTTP_PORT);
|
||||
assert_equals(B.parent, window, "window.parent works same-origin");
|
||||
assert_equals(C.parent, window, "window.parent works cross-origin");
|
||||
assert_equals(B.location.pathname, path, "location.href works same-origin");
|
||||
@@ -189,6 +193,8 @@ addTest(function() {
|
||||
* [[Delete]]
|
||||
*/
|
||||
addTest(function() {
|
||||
assert_throws(null, function() { delete C[0]; }, "Can't delete cross-origin indexed property");
|
||||
assert_throws(null, function() { delete C[100]; }, "Can't delete cross-origin indexed property");
|
||||
assert_throws(null, function() { delete C.location; }, "Can't delete cross-origin property");
|
||||
assert_throws(null, function() { delete C.parent; }, "Can't delete cross-origin property");
|
||||
assert_throws(null, function() { delete C.length; }, "Can't delete cross-origin property");
|
||||
@@ -306,20 +312,6 @@ addTest(function() {
|
||||
checkFunction(set_href_B, B.Function.prototype);
|
||||
}, "Same-origin observers get different accessors for cross-origin Location");
|
||||
|
||||
function doDocumentDomainTest(cb) {
|
||||
window.addEventListener('message', function onmessage(evt) {
|
||||
window.removeEventListener('message', onmessage);
|
||||
test(function() {
|
||||
var results = evt.data;
|
||||
assert_true(results.length > 0, 'Need results');
|
||||
results.forEach(function(r) { assert_true(r.pass, r.message); });
|
||||
}, "Cross-origin object identity preserved across document.domain");
|
||||
win.close();
|
||||
cb();
|
||||
});
|
||||
var win = window.open('win-documentdomain.sub.html');
|
||||
}
|
||||
|
||||
// We do a fresh load of the subframes for each test to minimize side-effects.
|
||||
// It would be nice to reload ourselves as well, but we can't do that without
|
||||
// disrupting the test harness.
|
||||
@@ -329,7 +321,7 @@ function runNextTest() {
|
||||
if (testList.length != 0)
|
||||
reloadSubframes(runNextTest);
|
||||
else
|
||||
doDocumentDomainTest(done); // Asynchronous.
|
||||
done();
|
||||
}
|
||||
reloadSubframes(runNextTest);
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
windowReferences.push(parent[i]);
|
||||
locationReferences.push(parent[i].location);
|
||||
}
|
||||
document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
|
||||
evt.source.postMessage('', '*');
|
||||
try {
|
||||
document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
|
||||
evt.source.postMessage('PASS', '*');
|
||||
} catch (e) {
|
||||
evt.source.postMessage('FAIL: cannot trim off document.domain: ' + e, '*');
|
||||
}
|
||||
}
|
||||
|
||||
function checkWindowReferences() {
|
||||
|
||||
@@ -19,23 +19,30 @@
|
||||
if (++loadCount == 4)
|
||||
go();
|
||||
}
|
||||
Array.forEach(document.getElementsByTagName('iframe'), function(ifr) { ifr.onload = frameLoaded; });
|
||||
var iframes = document.getElementsByTagName('iframe');
|
||||
for (var i = 0; i < iframes.length; i++) {
|
||||
iframes[i].onload = frameLoaded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var results = [];
|
||||
function assert(cond, msg) {
|
||||
results.push({pass: !!cond, message: msg});
|
||||
}
|
||||
|
||||
function go() {
|
||||
window.onmessage = function() {
|
||||
assert(B.checkWindowReferences(), "B's Window references are still self-consistent after document.domain");
|
||||
for (var i = 0; i < window.length; ++i) {
|
||||
assert(window[i] === B.windowReferences[i],
|
||||
"Window reference " + i + " consistent between globals after document.domain");
|
||||
assert(window[i].location === B.locationReferences[i],
|
||||
"Location reference " + i + " consistent between globals after document.domain");
|
||||
window.onmessage = function(evt) {
|
||||
try {
|
||||
assert(evt.data == "PASS", "frame.html processing should be PASS but got " + evt.data);
|
||||
assert(B.checkWindowReferences(), "B's Window references are still self-consistent after document.domain");
|
||||
for (var i = 0; i < window.length; ++i) {
|
||||
assert(window[i] === B.windowReferences[i],
|
||||
"Window reference " + i + " consistent between globals after document.domain");
|
||||
assert(window[i].location === B.locationReferences[i],
|
||||
"Location reference " + i + " consistent between globals after document.domain");
|
||||
}
|
||||
} catch(e) {
|
||||
assert(false, "Should not receive exception: " + e);
|
||||
}
|
||||
opener.postMessage(results, '*');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user