Added wpt tests for same-origin iframe parentage.

This commit is contained in:
Alan Jeffrey 2016-05-27 16:21:16 -05:00
parent cd1396fa9a
commit fa6fa6219f
6 changed files with 84 additions and 0 deletions

View file

@ -6442,6 +6442,12 @@
"url": "/_mozilla/mozilla/iframe-unblock-onload.html"
}
],
"mozilla/iframe/same_origin_parentage.html": [
{
"path": "mozilla/iframe/same_origin_parentage.html",
"url": "/_mozilla/mozilla/iframe/same_origin_parentage.html"
}
],
"mozilla/iframe_contentDocument.html": [
{
"path": "mozilla/iframe_contentDocument.html",

View file

@ -0,0 +1,26 @@
function get_test_results(id) {
async_test(function(test) {
var timer = window.setInterval(test.step_func(loop), 100);
function loop() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'stash.py?id=' + id);
xhr.onreadystatechange = test.step_func(function() {
assert_equals(xhr.status, 200);
if (xhr.responseText) {
assert_equals(xhr.responseText, "OK");
test.done();
window.clearTimeout(timer);
}
});
xhr.send();
}
});
}
function send_test_results(results) {
var ok = true;
for (result in results) { ok = ok && results[result]; }
var xhr = new XMLHttpRequest();
xhr.open('POST', 'stash.py?id=' + results.id);
xhr.send(ok ? "OK" : "FAIL: " + JSON.stringify(results));
}

View file

@ -0,0 +1,12 @@
<script src="iframe_harness.js"></script>
<body>
<iframe src="same_origin_grandchild.html"></iframe>
</body>
<script>
send_test_results({
"id": '08782f28-e313-47ae-8cd7-419f3e194b0a',
"parent": window.parent !== window,
"grandparent": window.parent.parent === window.parent,
"top": window.top === window.parent,
});
</script>

View file

@ -0,0 +1,11 @@
<script src="iframe_harness.js"></script>
<body>
</body>
<script>
send_test_results({
"id": '66de8d44-7da7-47c7-9a52-41cba4f22bfe',
"parent": window.parent !== window,
"grandparent": window.parent.parent !== window.parent,
"top": window.top === window.parent.parent,
});
</script>

View file

@ -0,0 +1,19 @@
<!doctype html>
<meta charset="utf-8">
<title>Check the frame heriarchy</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="iframe_harness.js"></script>
<body>
<iframe src="same_origin_child.html"></iframe>
</body>
<script>
get_test_results('17381dae-9c3e-4661-9f2b-28eb07a5f2fc');
get_test_results('08782f28-e313-47ae-8cd7-419f3e194b0a');
get_test_results('66de8d44-7da7-47c7-9a52-41cba4f22bfe');
send_test_results({
"id": '17381dae-9c3e-4661-9f2b-28eb07a5f2fc',
"parent": window.parent === window,
"top": window.top === window,
});
</script>

View file

@ -0,0 +1,10 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
def main(request, response):
if request.method == 'POST':
request.server.stash.put(request.GET["id"], request.body)
return ''
return request.server.stash.take(request.GET["id"])