Title: [137021] trunk
Revision
137021
Author
[email protected]
Date
2012-12-08 01:22:06 -0800 (Sat, 08 Dec 2012)

Log Message

HTMLTemplateElement.innerHTML should be parsed into the template contents owner document
https://bugs.webkit.org/show_bug.cgi?id=104407

Reviewed by Eric Seidel.

Source/WebCore:

When parsing via innerHTML, ensure that all operations (including the
initial fragment creation) occur in the proper document to avoid,
e.g., images loading while being parsed into the template contents.
This matches the parsing behavior during page load.

Test: fast/dom/HTMLTemplateElement/innerHTML-inert.html

* editing/markup.cpp:
(WebCore::createFragmentForInnerOuterHTML):

LayoutTests:

* fast/dom/HTMLTemplateElement/innerHTML-inert-expected.txt: Added.
* fast/dom/HTMLTemplateElement/innerHTML-inert.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (137020 => 137021)


--- trunk/LayoutTests/ChangeLog	2012-12-08 08:36:58 UTC (rev 137020)
+++ trunk/LayoutTests/ChangeLog	2012-12-08 09:22:06 UTC (rev 137021)
@@ -1,3 +1,13 @@
+2012-12-08  Adam Klein  <[email protected]>
+
+        HTMLTemplateElement.innerHTML should be parsed into the template contents owner document
+        https://bugs.webkit.org/show_bug.cgi?id=104407
+
+        Reviewed by Eric Seidel.
+
+        * fast/dom/HTMLTemplateElement/innerHTML-inert-expected.txt: Added.
+        * fast/dom/HTMLTemplateElement/innerHTML-inert.html: Added.
+
 2012-12-07  Stephen White  <[email protected]>
 
         [Chromium] Unreviewed gardening.

Added: trunk/LayoutTests/fast/dom/HTMLTemplateElement/innerHTML-inert-expected.txt (0 => 137021)


--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/innerHTML-inert-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/innerHTML-inert-expected.txt	2012-12-08 09:22:06 UTC (rev 137021)
@@ -0,0 +1,11 @@
+Blocked access to external URL http://active.com/bar.jpg
+Test that setting HTMLTemplateElement.innerHTML uses the inert document when creating elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS attemptedLoad is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLTemplateElement/innerHTML-inert.html (0 => 137021)


--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/innerHTML-inert.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/innerHTML-inert.html	2012-12-08 09:22:06 UTC (rev 137021)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src=""
+<script>
+description("Test that setting HTMLTemplateElement.innerHTML uses the inert document when creating elements");
+jsTestIsAsync = true;
+
+var template = document.createElement('template');
+var div = document.createElement('div');
+var attemptedLoad = false;
+function finish() {
+    shouldBeFalse('attemptedLoad');
+    finishJSTest();
+}
+
+template.innerHTML = '<img src="" _onerror_="attemptedLoad = true">';
+div.innerHTML = '<img src="" _onerror_="finish()">';
+</script>
+<script src=""

Modified: trunk/Source/WebCore/ChangeLog (137020 => 137021)


--- trunk/Source/WebCore/ChangeLog	2012-12-08 08:36:58 UTC (rev 137020)
+++ trunk/Source/WebCore/ChangeLog	2012-12-08 09:22:06 UTC (rev 137021)
@@ -1,3 +1,20 @@
+2012-12-08  Adam Klein  <[email protected]>
+
+        HTMLTemplateElement.innerHTML should be parsed into the template contents owner document
+        https://bugs.webkit.org/show_bug.cgi?id=104407
+
+        Reviewed by Eric Seidel.
+
+        When parsing via innerHTML, ensure that all operations (including the
+        initial fragment creation) occur in the proper document to avoid,
+        e.g., images loading while being parsed into the template contents.
+        This matches the parsing behavior during page load.
+
+        Test: fast/dom/HTMLTemplateElement/innerHTML-inert.html
+
+        * editing/markup.cpp:
+        (WebCore::createFragmentForInnerOuterHTML):
+
 2012-12-08  ChangSeok Oh  <[email protected]>
 
         Assertion failed at WebCore::RedirectedXCompositeWindow::context()

Modified: trunk/Source/WebCore/editing/markup.cpp (137020 => 137021)


--- trunk/Source/WebCore/editing/markup.cpp	2012-12-08 08:36:58 UTC (rev 137020)
+++ trunk/Source/WebCore/editing/markup.cpp	2012-12-08 09:22:06 UTC (rev 137021)
@@ -997,6 +997,10 @@
 PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String& markup, Element* contextElement, FragmentScriptingPermission scriptingPermission, ExceptionCode& ec)
 {
     Document* document = contextElement->document();
+#if ENABLE(TEMPLATE_ELEMENT)
+    if (contextElement->hasTagName(templateTag))
+        document = document->templateContentsOwnerDocument();
+#endif
     RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
 
     if (document->isHTMLDocument()) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to