-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Element/ShadowRoot's setHTMLUnsafe() and Document.parseHTMLUnsafe…
…() methods https://bugs.webkit.org/show_bug.cgi?id=261143 rdar://115345128 Reviewed by Ryosuke Niwa. This change implements these methods from the HTML Standard: https://html.spec.whatwg.org/#unsafe-html-parsing-methods Rename FragmentScriptingPermission.h to ParserContentPolicy.h as per the FIXME. Rename DeclarativeShadowDOM to DeclarativeShadowRoots to match the specification. Abstract the implementation of Element/ShadowRoot's setInnerHTML() so it can be reused by the new Element/ShadowRoot's setHTMLUnsafe(). Do the same for DOMParser to the benefit of Document.parseHTMLUnsafe(). Ensure that in both of those cases the new method can only go down the HTML parser path and has declarative shadow root support enabled. Put the new methods behind a DeclarativeShadowRootsParserAPIsEnabled preference (enabled by default) in case something is discovered to be amiss later on. Synchronize web-platform-tests: web-platform-tests/wpt@31655b3 Thanks to rniwa's earlier effort around the now-obsolete DOMParser API this was all relatively straightforward. Thanks rniwa! * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-encoding-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-encoding.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-style-attribute-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-style-attribute.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base-pushstate-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base-pushstate.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-moretests-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-moretests.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-pushstate-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-pushstate.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Element-setHTMLUnsafe-04-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/Element-setHTMLUnsafe-04.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-base-pushstate.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-base.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-pushstate.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe.js: Added. (window.doParse): * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-url-tests.js: Added. (assertURL): (input.of.Object.entries): * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/w3c-import.log: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-CEReactions-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-CEReactions.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-xml-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-xml.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/w3c-import.log: Added. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-basic-expected.txt: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Headers.cmake: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/DOMImplementation.cpp: * Source/WebCore/dom/Document.cpp: (WebCore::Document::parseMarkupUnsafe): (WebCore::Document::parseHTMLUnsafe): * Source/WebCore/dom/Document.h: * Source/WebCore/dom/Document.idl: * Source/WebCore/dom/DocumentFragment.h: * Source/WebCore/dom/Element.cpp: (WebCore::Element::replaceChildrenWithMarkup): (WebCore::Element::setHTMLUnsafe): (WebCore::Element::setInnerHTML): * Source/WebCore/dom/Element.h: * Source/WebCore/dom/InnerHTML.idl: * Source/WebCore/dom/ParserContentPolicy.h: Renamed from Source/WebCore/dom/FragmentScriptingPermission.h. * Source/WebCore/dom/ScriptableDocumentParser.h: * Source/WebCore/dom/ShadowRoot.cpp: (WebCore::ShadowRoot::replaceChildrenWithMarkup): (WebCore::ShadowRoot::setHTMLUnsafe): (WebCore::ShadowRoot::innerHTML const): (WebCore::ShadowRoot::setInnerHTML): * Source/WebCore/dom/ShadowRoot.h: * Source/WebCore/dom/ShadowRootInit.idl: * Source/WebCore/editing/markup.cpp: (WebCore::createFragmentForMarkup): * Source/WebCore/editing/markup.h: * Source/WebCore/html/HTMLTemplateElement.idl: * Source/WebCore/html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::HTMLConstructionSite): (WebCore::HTMLConstructionSite::insertHTMLTemplateElement): * Source/WebCore/html/parser/HTMLConstructionSite.h: * Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp: * Source/WebCore/xml/DOMParser.cpp: (WebCore::DOMParser::parseFromString): * Source/WebCore/xml/parser/XMLDocumentParser.h: * Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp: Canonical link: https://commits.webkit.org/271423@main
- Loading branch information
Showing
59 changed files
with
1,424 additions
and
752 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...namic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-encoding-expected.txt
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,5 @@ | ||
|
||
PASS Parse empty string | ||
PASS meta charset latin2 | ||
PASS XML declaration | ||
|
35 changes: 35 additions & 0 deletions
35
...papis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-encoding.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,35 @@ | ||
<!DOCTYPE html> | ||
<meta charset="windows-1252"> <!-- intentional to make sure the results are UTF-8 anyway --> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<link rel=help href="https://github.com/whatwg/html/pull/9538"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<!-- This was adapted from DOMParser-parseFromString-encoding.html --> | ||
|
||
<script> | ||
function assertEncoding(doc) { | ||
assert_equals(doc.charset, "UTF-8", "document.charset"); | ||
assert_equals(doc.characterSet, "UTF-8", "document.characterSet"); | ||
assert_equals(doc.inputEncoding, "UTF-8", "document.characterSet"); | ||
} | ||
|
||
setup(() => { | ||
assert_equals(document.characterSet, "windows-1252", "the meta charset must be in effect, making the main document windows-1252"); | ||
}); | ||
|
||
test(() => { | ||
const doc = Document.parseHTMLUnsafe(''); | ||
assertEncoding(doc); | ||
}, 'Parse empty string'); | ||
|
||
test(() => { | ||
const doc = Document.parseHTMLUnsafe(`<meta charset="latin2">`); | ||
assertEncoding(doc); | ||
}, "meta charset latin2"); | ||
|
||
test(() => { | ||
const doc = Document.parseHTMLUnsafe(`<?xml version="1.0" encoding="latin2"?><x/>`); | ||
assertEncoding(doc); | ||
}, "XML declaration"); | ||
</script> |
11 changes: 11 additions & 0 deletions
11
...ppapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-expected.txt
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,11 @@ | ||
|
||
PASS Parsing of id attribute | ||
PASS contentType | ||
PASS compatMode | ||
PASS compatMode for a proper DOCTYPE | ||
PASS Location value | ||
PASS Document.parseHTMLUnsafe parses HTML tag soup with no problems | ||
PASS Document.parseHTMLUnsafe should handle the content of <noembed> as raw text | ||
PASS script is found synchronously even when there is a css import | ||
PASS must be parsed with scripting disabled, so noscript works | ||
|
6 changes: 6 additions & 0 deletions
6
...arkup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-style-attribute-expected.txt
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,6 @@ | ||
|
||
PASS Parsing of initial style attribute | ||
PASS Parsing of invalid style attribute | ||
PASS Parsing of style attribute | ||
PASS Update style.backgroundColor | ||
|
54 changes: 54 additions & 0 deletions
54
...ynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-style-attribute.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,54 @@ | ||
<!doctype html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This test was adapted from style_attribute_html.html --> | ||
<meta charset=utf-8> | ||
<title>Style attribute in HTML</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
|
||
var div; | ||
setup(function() { | ||
var input = '<div style="color: red">Foo</div>'; | ||
var doc = Document.parseHTMLUnsafe(input); | ||
div = doc.querySelector('div'); | ||
}); | ||
|
||
test(function() { | ||
var style = div.style; | ||
assert_equals(style.cssText, 'color: red;'); | ||
assert_equals(style.color, 'red'); | ||
assert_equals(div.getAttribute("style"), 'color: red', | ||
'Value of style attribute should match the string value that was set'); | ||
}, 'Parsing of initial style attribute'); | ||
|
||
test(function() { | ||
var style = div.style; | ||
div.setAttribute('style', 'color:: invalid'); | ||
assert_equals(style.cssText, ''); | ||
assert_equals(style.color, ''); | ||
assert_equals(div.getAttribute('style'), 'color:: invalid', | ||
'Value of style attribute should match the string value that was set'); | ||
}, 'Parsing of invalid style attribute'); | ||
|
||
test(function() { | ||
var style = div.style; | ||
div.setAttribute('style', 'color: green'); | ||
assert_equals(style.cssText, 'color: green;'); | ||
assert_equals(style.color, 'green'); | ||
assert_equals(div.getAttribute('style'), 'color: green', | ||
'Value of style attribute should match the string value that was set'); | ||
}, 'Parsing of style attribute'); | ||
|
||
test(function() { | ||
var style = div.style; | ||
style.backgroundColor = 'blue'; | ||
assert_equals(style.cssText, 'color: green; background-color: blue;', | ||
'Should not drop the existing style'); | ||
assert_equals(style.color, 'green', | ||
'Should not drop the existing style'); | ||
assert_equals(div.getAttribute('style'), 'color: green; background-color: blue;', | ||
'Should update style attribute'); | ||
}, 'Update style.backgroundColor'); | ||
|
||
</script> |
9 changes: 9 additions & 0 deletions
9
...namic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base-expected.txt
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,9 @@ | ||
|
||
|
||
PASS valid: created normally | ||
PASS valid: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS valid: created using another iframe's parseHTMLUnsafe from that frame | ||
PASS invalid XML: created normally | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from that frame | ||
|
9 changes: 9 additions & 0 deletions
9
...up-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base-pushstate-expected.txt
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,9 @@ | ||
|
||
|
||
PASS valid: created normally | ||
PASS valid: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS valid: created using another iframe's parseHTMLUnsafe from that frame | ||
PASS invalid XML: created normally | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from that frame | ||
|
15 changes: 15 additions & 0 deletions
15
...mic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base-pushstate.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,15 @@ | ||
<!doctype html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This test was adapted from DOMParser-parseFromString-url-base-pushstate.html --> | ||
<title>parseHTMLUnsafe test of how the document's URL is set (base, pushstate)</title> | ||
<base href="/fake/base-from-outer-frame"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<iframe src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-base-pushstate.html" onload="window.resolveLoadPromise();"></iframe> | ||
|
||
<script> | ||
"use strict"; | ||
history.pushState(null, "", "/fake/push-state-from-outer-frame"); | ||
</script> | ||
<script src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-url-tests.js"></script> |
10 changes: 10 additions & 0 deletions
10
...papis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-base.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,10 @@ | ||
<!doctype html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This was adapted from DOMParser-parseFromString-url-base.html --> | ||
<title>parseHTMLUnsafe test of how the document's URL is set (base, no pushstate)</title> | ||
<base href="/fake/base-from-outer-frame"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<iframe src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-base.html" onload="window.resolveLoadPromise();"></iframe> | ||
<script src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-url-tests.js"></script> |
9 changes: 9 additions & 0 deletions
9
...is/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-expected.txt
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,9 @@ | ||
|
||
|
||
PASS valid: created normally | ||
PASS valid: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS valid: created using another iframe's parseHTMLUnsafe from that frame | ||
PASS invalid XML: created normally | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from that frame | ||
|
7 changes: 7 additions & 0 deletions
7
...-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-moretests-expected.txt
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,7 @@ | ||
|
||
PASS Document.parseHTMLUnsafe: Document's url | ||
PASS Parent window | ||
PASS Child window | ||
PASS Child window crossing navigation | ||
PASS Child window after navigation | ||
|
42 changes: 42 additions & 0 deletions
42
.../dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-moretests.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,42 @@ | ||
<!DOCTYPE html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This test was adapted from DOMParser-parseFromString-url-moretests.html --> | ||
<meta charset=utf-8> | ||
<title>Document.parseHTMLUnsafe: Document's url</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id=log></div> | ||
<script> | ||
async_test(function() { | ||
var iframe = document.createElement("iframe"); | ||
iframe.onload = this.step_func(function() { | ||
var child = iframe.contentWindow; | ||
|
||
test(function() { | ||
var doc = Document.parseHTMLUnsafe("<html></html>"); | ||
assert_equals(doc.URL, "about:blank"); | ||
}, "Parent window"); | ||
|
||
test(function() { | ||
var doc = child.Document.parseHTMLUnsafe("<html></html>"); | ||
assert_equals(doc.URL, "about:blank"); | ||
}, "Child window"); | ||
|
||
var dpBeforeNavigation = child.Document, urlBeforeNavigation = child.document.URL; | ||
iframe.onload = this.step_func_done(function() { | ||
test(function() { | ||
var doc = dpBeforeNavigation.parseHTMLUnsafe("<html></html>"); | ||
assert_equals(doc.URL, "about:blank"); | ||
}, "Child window crossing navigation"); | ||
|
||
test(function() { | ||
var doc = child.Document.parseHTMLUnsafe("<html></html>"); | ||
assert_equals(doc.URL, "about:blank"); | ||
}, "Child window after navigation"); | ||
}); | ||
iframe.src = "/common/blank.html?2"; | ||
}); | ||
iframe.src = "/common/blank.html?1"; | ||
document.body.appendChild(iframe); | ||
}); | ||
</script> |
9 changes: 9 additions & 0 deletions
9
...-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-pushstate-expected.txt
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,9 @@ | ||
|
||
|
||
PASS valid: created normally | ||
PASS valid: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS valid: created using another iframe's parseHTMLUnsafe from that frame | ||
PASS invalid XML: created normally | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from this frame | ||
PASS invalid XML: created using another iframe's parseHTMLUnsafe from that frame | ||
|
14 changes: 14 additions & 0 deletions
14
.../dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url-pushstate.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,14 @@ | ||
<!doctype html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This test was adapted from DOMParser-parseFromString-url-pushstate.html --> | ||
<title>parseHTMLUnsafe test of how the document's URL is set (no base, pushstate)</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<iframe src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-pushstate.html" onload="window.resolveLoadPromise();"></iframe> | ||
|
||
<script> | ||
"use strict"; | ||
history.pushState(null, "", "/fake/push-state-from-outer-frame"); | ||
</script> | ||
<script src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-url-tests.js"></script> |
9 changes: 9 additions & 0 deletions
9
...webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe-url.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,9 @@ | ||
<!doctype html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This test was adapted from DOMParser-parseFromString-url.html --> | ||
<title>parseHTMLUnsafe test of how the document's URL is set (no pushstate, no base)</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<iframe src="resources/parseHTMLUnsafe-iframe.html" onload="window.resolveLoadPromise();"></iframe> | ||
<script src="resources/parseHTMLUnsafe-url-tests.js"></script> |
77 changes: 77 additions & 0 deletions
77
...tml/webappapis/dynamic-markup-insertion/html-unsafe-methods/Document-parseHTMLUnsafe.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,77 @@ | ||
<!doctype html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This was adapted from DOMParser-parseFromString-html.html --> | ||
<title>parseHTMLUnsafe basic test of HTML parsing</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
// |expected| should be an object indicating the expected type of node. | ||
function assert_node(actual, expected) { | ||
assert_true(actual instanceof expected.type, | ||
'Node type mismatch: actual = ' + actual.constructor.name + ', expected = ' + expected.type.name); | ||
if (typeof(expected.id) !== 'undefined') | ||
assert_equals(actual.id, expected.id, expected.idMessage); | ||
} | ||
|
||
var doc; | ||
setup(function() { | ||
doc = Document.parseHTMLUnsafe('<html id="root"><head></head><body></body></html>'); | ||
}); | ||
|
||
test(function() { | ||
var root = doc.documentElement; | ||
assert_node(root, { type: HTMLHtmlElement, id: 'root', | ||
idMessage: 'documentElement id attribute should be root.' }); | ||
}, 'Parsing of id attribute'); | ||
|
||
test(function() { | ||
assert_equals(doc.contentType, "text/html") | ||
}, 'contentType'); | ||
|
||
test(function() { | ||
assert_equals(doc.compatMode, "BackCompat") | ||
}, 'compatMode'); | ||
|
||
test(function() { | ||
doc = Document.parseHTMLUnsafe('<!DOCTYPE html><html id="root"><head></head><body></body></html>'); | ||
assert_equals(doc.compatMode, "CSS1Compat") | ||
}, 'compatMode for a proper DOCTYPE'); | ||
|
||
// URL- and encoding-related stuff tested separately. | ||
|
||
test(function() { | ||
assert_equals(doc.location, null, | ||
'The document must have a location value of null.'); | ||
}, 'Location value'); | ||
|
||
test(function() { | ||
var htmldoc = Document.parseHTMLUnsafe("<!DOCTYPE foo></><foo></multiple></>"); | ||
assert_equals(htmldoc.documentElement.localName, "html"); | ||
assert_equals(htmldoc.documentElement.namespaceURI, "http://www.w3.org/1999/xhtml"); | ||
}, "Document.parseHTMLUnsafe parses HTML tag soup with no problems"); | ||
|
||
test(function() { | ||
const doc = Document.parseHTMLUnsafe('<noembed><a></noembed>'); | ||
assert_equals(doc.querySelector('noembed').textContent, '<a>'); | ||
}, 'Document.parseHTMLUnsafe should handle the content of <noembed> as raw text'); | ||
|
||
test(() => { | ||
const doc = Document.parseHTMLUnsafe(` | ||
<html><body> | ||
<style> | ||
@import url(/dummy.css) | ||
</style> | ||
<script>document.x = 8<\/script> | ||
</body></html>`); | ||
|
||
assert_not_equals(doc.querySelector('script'), null, 'script must be found'); | ||
assert_equals(doc.x, undefined, 'script must not be executed on the inner document'); | ||
assert_equals(document.x, undefined, 'script must not be executed on the outer document'); | ||
}, 'script is found synchronously even when there is a css import'); | ||
|
||
test(() => { | ||
const doc = Document.parseHTMLUnsafe(`<body><noscript><p id="test1">test1<p id="test2">test2</noscript>`); | ||
assert_node(doc.body.firstChild.childNodes[0], { type: HTMLParagraphElement, id: 'test1' }); | ||
assert_node(doc.body.firstChild.childNodes[1], { type: HTMLParagraphElement, id: 'test2' }); | ||
}, 'must be parsed with scripting disabled, so noscript works'); | ||
</script> |
3 changes: 3 additions & 0 deletions
3
...ppapis/dynamic-markup-insertion/html-unsafe-methods/Element-setHTMLUnsafe-04-expected.txt
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,3 @@ | ||
|
||
PASS setHTMLUnsafe should leave the removed children alone. | ||
|
25 changes: 25 additions & 0 deletions
25
...tml/webappapis/dynamic-markup-insertion/html-unsafe-methods/Element-setHTMLUnsafe-04.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,25 @@ | ||
<!DOCTYPE html> | ||
<title>setHTMLUnsafe in HTML</title> | ||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<!-- This test was adapted from innerhtml-04.html --> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
function testIsChild(p, c) { | ||
assert_equals(p.firstChild, c); | ||
assert_equals(c.parentNode, p); | ||
} | ||
test(function() { | ||
var p = document.createElement('p'); | ||
var b = p.appendChild(document.createElement('b')); | ||
var t = b.appendChild(document.createTextNode("foo")); | ||
testIsChild(p, b); | ||
testIsChild(b, t); | ||
assert_equals(t.data, "foo"); | ||
p.setHTMLUnsafe(""); | ||
testIsChild(b, t); | ||
assert_equals(t.data, "foo"); | ||
}, "setHTMLUnsafe should leave the removed children alone.") | ||
</script> |
10 changes: 10 additions & 0 deletions
10
...markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-base-pushstate.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,10 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>An iframe that does parseHTMLUnsafe stuff with base and pushstates itself</title> | ||
<base href="/fake/base-from-iframe"> | ||
|
||
<script> | ||
"use strict"; | ||
history.pushState(null, "", "/fake/push-state-from-iframe"); | ||
</script> | ||
<script src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe.js"></script> |
6 changes: 6 additions & 0 deletions
6
...s/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-base.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,6 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>An iframe that does parseHTMLUnsafe stuff with base</title> | ||
<base href="/fake/base-from-iframe"> | ||
|
||
<script src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe.js"></script> |
9 changes: 9 additions & 0 deletions
9
...amic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe-pushstate.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,9 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>An iframe that does parseHTMLUnsafe stuff and pushstates itself</title> | ||
|
||
<script> | ||
"use strict"; | ||
history.pushState(null, "", "/fake/push-state-from-iframe"); | ||
</script> | ||
<script src="/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe.js"></script> |
4 changes: 4 additions & 0 deletions
4
...ppapis/dynamic-markup-insertion/html-unsafe-methods/resources/parseHTMLUnsafe-iframe.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,4 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>An iframe that does parseHTMLUnsafe stuff</title> | ||
<script src="parseHTMLUnsafe-iframe.js"></script> |
Oops, something went wrong.