Auto merge of #11644 - asajeffrey:mozbrowser-top-level-browsing-context, r=ConnerGBrewster

Mozbrowser top level browsing context

<!-- Please describe your changes on the following line: -->
Got `window.top` and `window.parent` to return the right result inside a `mozbrowser` iframe.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11644)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-07 13:27:44 -05:00
commit 280bfc961a
15 changed files with 180 additions and 76 deletions

View file

@ -6550,6 +6550,12 @@
"url": "/_mozilla/mozilla/mozbrowser/mozbrowser_click_fires_openwindow.html"
}
],
"mozilla/mozbrowser/mozbrowser_iframe_parentage.html": [
{
"path": "mozilla/mozbrowser/mozbrowser_iframe_parentage.html",
"url": "/_mozilla/mozilla/mozbrowser/mozbrowser_iframe_parentage.html"
}
],
"mozilla/mozbrowser/mozbrowser_loadevents.html": [
{
"path": "mozilla/mozbrowser/mozbrowser_loadevents.html",

View file

@ -0,0 +1,11 @@
<script src="mozbrowser_iframe_harness.js"></script>
<body>
<iframe src="mozbrowser_iframe_grandchild.html"></iframe>
</body>
<script>
send_test_results({
"id": 'aaee4290-6a78-4932-a1d1-fbbe158fb473',
"parent": window.parent === window,
"top": window.top === window,
});
</script>

View file

@ -0,0 +1,11 @@
<script src="mozbrowser_iframe_harness.js"></script>
<body>
</body>
<script>
send_test_results({
"id": 'a94c0025-08dc-49a6-8f98-fbbaacfdd296',
"parent": window.parent !== window,
"grandparent": window.parent.parent === window.parent,
"top": window.top === window.parent,
});
</script>

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,23 @@
<!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="mozbrowser_iframe_harness.js"></script>
<body>
</body>
<script>
var iframe = document.createElement("iframe");
iframe.mozbrowser = "true";
iframe.src = "mozbrowser_iframe_child.html";
document.body.appendChild(iframe);
get_test_results('cdea5bf0-667e-407c-878c-6b5cfa623fd6');
get_test_results('aaee4290-6a78-4932-a1d1-fbbe158fb473');
get_test_results('a94c0025-08dc-49a6-8f98-fbbaacfdd296');
send_test_results({
"id": 'cdea5bf0-667e-407c-878c-6b5cfa623fd6',
"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"])