mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Added a test for changing an iframe's parentage.
This commit is contained in:
parent
77e0089c12
commit
999e057cb7
10 changed files with 52 additions and 6 deletions
|
@ -0,0 +1,14 @@
|
|||
<body>
|
||||
Child.
|
||||
<iframe id="grandchild" src="change_grandchild.html"></iframe>
|
||||
</body>
|
||||
<script>
|
||||
var timer = window.setInterval(poll, 100);
|
||||
function poll() {
|
||||
if (document.body.getAttribute("data-contains-grandchild")) {
|
||||
var grandchild = document.getElementById("grandchild");
|
||||
window.frameElement.parentNode.appendChild(grandchild);
|
||||
window.clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,4 @@
|
|||
<body>Grandchild.</body>
|
||||
<script>
|
||||
window.frameElement.parentNode.setAttribute("data-contains-grandchild", true);
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Change the frame heriarchy</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<iframe src="change_child.html"></iframe>
|
||||
</body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var timer = window.setInterval(t.step_func(poll), 100);
|
||||
function poll() {
|
||||
// We wait for the grandchild's script to set the custom attribtue.
|
||||
// Note that if this test passes, the grandchild's script must have been run twice,
|
||||
// once to trigger the move from the child to here, and once to pass this test.
|
||||
if (document.body.getAttribute("data-contains-grandchild")) {
|
||||
window.clearTimeout(timer);
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -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));
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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"])
|
Loading…
Add table
Add a link
Reference in a new issue