Commit 7692f47b authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Ensure that cloned documents inherit the underlying security origin.

This was changed in https://crrev.com/388754 for
DOMImplementation createDocument and should have been done the same
for cloneNode. This brings our implementation in alignment with Firefox.

BUG=605203

Change-Id: I501ae7ea21dc8017e3f21181aed6cf274a71a728
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1927024
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718812}
parent 0eeb5fd9
......@@ -5103,11 +5103,10 @@ Node* Document::Clone(Document& factory, CloneChildrenFlag flag) const {
}
Document* Document::CloneDocumentWithoutChildren() const {
DocumentInit init =
DocumentInit::Create()
.WithContextDocument(ContextDocument())
.WithURL(Url())
.WithOriginToCommit(GetSecurityOrigin()->IsolatedCopy());
DocumentInit init = DocumentInit::Create()
.WithContextDocument(ContextDocument())
.WithOwnerDocument(const_cast<Document*>(this))
.WithURL(Url());
if (IsXMLDocument()) {
if (IsXHTMLDocument())
return XMLDocument::CreateXHTML(
......
......@@ -78,9 +78,9 @@ Document* HTMLDocument::CloneDocumentWithoutChildren() const {
return MakeGarbageCollected<HTMLDocument>(
DocumentInit::Create()
.WithContextDocument(ContextDocument())
.WithOwnerDocument(const_cast<HTMLDocument*>(this))
.WithURL(Url())
.WithRegistrationContext(RegistrationContext())
.WithOriginToCommit(GetSecurityOrigin()->IsolatedCopy()));
.WithRegistrationContext(RegistrationContext()));
}
// --------------------------------------------------------------------------
......
......@@ -14,20 +14,10 @@
document.domain = 'example.test';
assert_equals(document.domain, 'example.test');
assert_equals(doc.domain, 'subdomain.example.test');
assert_equals(doc.domain, 'example.test');
document.domain = 'subdomain.example.test';
}, "Cloned documents do not share the underlying domain after the clone.");
test(function () {
assert_equals(document.domain, 'subdomain.example.test');
document.domain = 'example.test';
var doc = document.cloneNode(true);
assert_equals(document.domain, 'example.test');
assert_equals(doc.domain, 'example.test');
}, "Cloned documents inherit the underlying domain.");
}, "Cloned documents share the underlying domain after the clone.");
}
</script>
</head>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment