mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Update web-platform-tests to revision 345300fad3945a5f1441fb2b2001109ca48f36e8
This commit is contained in:
parent
71ba247942
commit
05db47be0f
109 changed files with 2576 additions and 1228 deletions
|
@ -1,82 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<!-- SEKRITS! -->
|
||||
<input id="sekrit" value="omg!">
|
||||
|
||||
<script>
|
||||
function postMessageToFrame(frame, message) {
|
||||
return new Promise(resolve => {
|
||||
var c = new MessageChannel();
|
||||
c.port1.onmessage = e => {
|
||||
resolve({ data: e.data, frame: frame })
|
||||
};
|
||||
frame.contentWindow.postMessage(message, '*', [c.port2]);
|
||||
});
|
||||
}
|
||||
|
||||
function createFrame() {
|
||||
return new Promise(resolve => {
|
||||
var i = document.createElement('iframe');
|
||||
i.src = "./support/document_domain_frame.html";
|
||||
window.addEventListener('message', m => {
|
||||
if (m.source == i.contentWindow)
|
||||
resolve(i);
|
||||
});
|
||||
document.body.appendChild(i);
|
||||
});
|
||||
}
|
||||
|
||||
promise_test(t => {
|
||||
return createFrame()
|
||||
.then(f => postMessageToFrame(f, 'poke-at-parent'))
|
||||
.then(result => {
|
||||
assert_equals(result.data, document.querySelector('#sekrit').value);
|
||||
result.frame.remove();
|
||||
});
|
||||
}, "Access allowed with no 'document.domain' modification. (Sanity check)");
|
||||
|
||||
promise_test(t => {
|
||||
return createFrame()
|
||||
.then(f => postMessageToFrame(f, { domain: null }))
|
||||
.then(result => {
|
||||
assert_equals(result.data, 'Done');
|
||||
return postMessageToFrame(result.frame, 'poke-at-parent')
|
||||
.then(result => {
|
||||
assert_equals(result.data, 'SecurityError');
|
||||
result.frame.remove();
|
||||
});
|
||||
});
|
||||
}, "No access when frame sets a `null` 'document.domain'.");
|
||||
|
||||
promise_test(t => {
|
||||
return createFrame()
|
||||
.then(f => {
|
||||
document.domain = null;
|
||||
assert_equals(document.domain, "null");
|
||||
return postMessageToFrame(f, 'poke-at-parent');
|
||||
})
|
||||
.then(result => {
|
||||
assert_equals(result.data, 'SecurityError');
|
||||
result.frame.remove();
|
||||
});
|
||||
}, "No access when parent sets a `null` 'document.domain'.");
|
||||
|
||||
promise_test(t => {
|
||||
return createFrame()
|
||||
.then(f => {
|
||||
document.domain = null;
|
||||
assert_equals(document.domain, "null");
|
||||
return postMessageToFrame(f, { domain: null });
|
||||
})
|
||||
.then(result => {
|
||||
assert_equals(result.data, 'Done');
|
||||
return postMessageToFrame(result.frame, 'poke-at-parent')
|
||||
.then(result => {
|
||||
assert_equals(result.data, 'SecurityError');
|
||||
result.frame.remove();
|
||||
});
|
||||
});
|
||||
}, "No access when both sides set a `null` 'document.domain'.");
|
||||
</script>
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
window.addEventListener('message', e => {
|
||||
if (e.data.domain !== undefined) {
|
||||
try {
|
||||
document.domain = e.data.domain;
|
||||
e.ports[0].postMessage('Done');
|
||||
} catch(error) {
|
||||
e.ports[0].postMessage(error.name);
|
||||
}
|
||||
} else if (e.data == 'poke-at-parent') {
|
||||
try {
|
||||
var sekrit = window.parent.document.body.querySelector('#sekrit').value;
|
||||
e.ports[0].postMessage(sekrit);
|
||||
} catch(error) {
|
||||
e.ports[0].postMessage(error.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
window.parent.postMessage('Hi!', '*');
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue