Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mozilla wpt test for adopted nodes passing same-origin-domain c…
…hecks.
- Loading branch information
Alan Jeffrey
committed
May 2, 2017
1 parent
688733a
commit 71f3d8a
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/wpt/mozilla/meta/mozilla/adopted_node_is_same_origin_domain.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[adopted_node_is_same_origin_domain.html] | ||
type: testharness | ||
[Adopting a node should make it same-origin-domain.] | ||
expected: FAIL |
30 changes: 30 additions & 0 deletions
30
tests/wpt/mozilla/tests/mozilla/adopted_node_is_same_origin_domain.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |