Skip to content

Commit

Permalink
Added mozilla wpt test for adopted nodes passing same-origin-domain c…
Browse files Browse the repository at this point in the history
…hecks.
  • Loading branch information
Alan Jeffrey committed May 2, 2017
1 parent 688733a commit 71f3d8a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -11369,6 +11369,12 @@
{}
]
],
"mozilla/adopted_node_is_same_origin_domain.html": [
[
"/_mozilla/mozilla/adopted_node_is_same_origin_domain.html",
{}
]
],
"mozilla/binding_keyword.html": [
[
"/_mozilla/mozilla/binding_keyword.html",
Expand Down Expand Up @@ -24492,6 +24498,10 @@
"170d51460da58c16f5cf94ecda18f18a1c18c116",
"support"
],
"mozilla/adopted_node_is_same_origin_domain.html": [
"3f2e6af92f9391aa1892e485c61c9e92c7661194",
"testharness"
],
"mozilla/binding_keyword.html": [
"c79aa6d506fbabbed0f6f31d1b8600ea6ba8ff41",
"testharness"
Expand Down
@@ -0,0 +1,4 @@
[adopted_node_is_same_origin_domain.html]
type: testharness
[Adopting a node should make it same-origin-domain.]
expected: FAIL
@@ -0,0 +1,30 @@
<!doctype html>
<meta charset=utf-8>
<title>Ensure that adopted nodes pass the same-origin-domain checks</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-adoptnode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(function(t) {
// This tests that adopting a node changes its same-origin-domain checks.
var iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.onload = t.step_func(function() {
// Create two nodes in the iframe's content document.
var nodeToAdopt = iframe.contentDocument.createElement("div");
var nodeToLeaveUnadopted = iframe.contentDocument.createElement("div");
document.adoptNode(nodeToAdopt);
assert_equals(nodeToAdopt.ownerDocument, document);
assert_equals(nodeToLeaveUnadopted.ownerDocument, iframe.contentDocument);
// Setting the iframe's document.domain causes it not to be same-origin-domain
iframe.contentDocument.domain = document.domain;
// We can still access the adopted node, since it is still same-origin-domain,
// but accessing the unadopted node throws a security exception.
assert_equals(nodeToAdopt.ownerDocument, document);
assert_throws(null, function() { nodeToLeaveUnadopted.ownerDocument; });
t.done();
});
document.body.appendChild(iframe);
}, "Adopting a node should make it same-origin-domain.")
</script>

0 comments on commit 71f3d8a

Please sign in to comment.