Diff
Modified: trunk/LayoutTests/ChangeLog (139501 => 139502)
--- trunk/LayoutTests/ChangeLog 2013-01-11 22:42:45 UTC (rev 139501)
+++ trunk/LayoutTests/ChangeLog 2013-01-11 22:45:35 UTC (rev 139502)
@@ -1,3 +1,13 @@
+2013-01-11 Rafael Weinstein <[email protected]>
+
+ Prevent HTMLPreloadScanner from fetching resources inside <template>
+ https://bugs.webkit.org/show_bug.cgi?id=106687
+
+ Reviewed by Adam Barth.
+
+ * fast/dom/HTMLTemplateElement/inertContents-expected.txt:
+ * fast/dom/HTMLTemplateElement/inertContents.html:
+
2013-01-11 Stephen Chenney <[email protected]>
[Chromium] More test expectations for Skia changes
Modified: trunk/LayoutTests/fast/dom/HTMLTemplateElement/inertContents-expected.txt (139501 => 139502)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/inertContents-expected.txt 2013-01-11 22:42:45 UTC (rev 139501)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/inertContents-expected.txt 2013-01-11 22:45:35 UTC (rev 139502)
@@ -1,11 +1,7 @@
-The test asserts that elements within template contents are "inert", e.g. script does not run.
+http://foo.com/shouldLoad.jpg - willSendRequest <NSURLRequest URL http://foo.com/shouldLoad.jpg, main document URL inertContents.html, http method GET> redirectResponse (null)
+Blocked access to external URL http://foo.com/shouldLoad.jpg
+http://foo.com/shouldLoad.jpg - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "(null)">
+The test asserts that elements within template contents are "inert", e.g. resources do not fetch, script does not run.
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+Before template content insertion: script did not run, after template content insertion: script did run.
-
-PASS testVal is "script has not run"
-PASS testVal is "script has run"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
Modified: trunk/LayoutTests/fast/dom/HTMLTemplateElement/inertContents.html (139501 => 139502)
--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/inertContents.html 2013-01-11 22:42:45 UTC (rev 139501)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/inertContents.html 2013-01-11 22:45:35 UTC (rev 139502)
@@ -1,17 +1,29 @@
-<!DOCTYPE html>
<body>
-<script src=""
+<p>The test asserts that elements within template contents are "inert", e.g. resources do not fetch, script does not run.</p>
+<template id="template"><script>window.testVal = "script did run";</script><img src=""
+<div id="output">
+</div>
+
<script>
-var testVal = 'script has not run';
+var testVal = "script did not run";
+
+window._onload_ = function() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpResourceLoadCallbacks();
+ }
+
+ var output = document.getElementById('output');
+ output.innerHTML = 'Before template content insertion: ' + testVal;
+
+ var templateContent = document.getElementById('template').content;
+ var img = templateContent.childNodes[1];
+ img.src = ""
+ document.body.appendChild(templateContent);
+
+ output.innerHTML += ', after template content insertion: ' + testVal + '.';
+}
</script>
-<!-- FIXME: Add non-flaky test for <img> tags -->
-<template><script>window.testVal = 'script has run';</script></template>
-<script>
-description('The test asserts that elements within template contents are "inert", e.g. script does not run.');
-shouldBeEqualToString('testVal', 'script has not run');
-var templateContent = document.querySelector('template').content;
-document.body.appendChild(templateContent);
-shouldBeEqualToString('testVal', 'script has run');
-</script>
-<script src=""
+</head>
+<body>
</body>
Modified: trunk/Source/WebCore/ChangeLog (139501 => 139502)
--- trunk/Source/WebCore/ChangeLog 2013-01-11 22:42:45 UTC (rev 139501)
+++ trunk/Source/WebCore/ChangeLog 2013-01-11 22:45:35 UTC (rev 139502)
@@ -1,3 +1,22 @@
+2013-01-11 Rafael Weinstein <[email protected]>
+
+ Prevent HTMLPreloadScanner from fetching resources inside <template>
+ https://bugs.webkit.org/show_bug.cgi?id=106687
+
+ Reviewed by Adam Barth.
+
+ This patch adds a simple counter to the preload scanner which increments on template start
+ tag and decrements on template element. It only fetchs resources when the counter is at zero
+ (i.e. for elements not contained by a template element).
+
+ Test re-enabled within fast/dom/HTMLTemplateElement/inertContents.html
+
+ * html/parser/HTMLPreloadScanner.cpp:
+ (WebCore::HTMLPreloadScanner::HTMLPreloadScanner):
+ (WebCore::HTMLPreloadScanner::processToken):
+ * html/parser/HTMLPreloadScanner.h:
+ (HTMLPreloadScanner):
+
2013-01-11 Tony Gentilcore <[email protected]>
We should be able to checkpoint and restore the HTMLTokenizer across threads
Modified: trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (139501 => 139502)
--- trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2013-01-11 22:42:45 UTC (rev 139501)
+++ trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2013-01-11 22:45:35 UTC (rev 139502)
@@ -167,6 +167,9 @@
, m_cssScanner(document)
, m_tokenizer(HTMLTokenizer::create(options))
, m_inStyle(false)
+#if ENABLE(TEMPLATE_ELEMENT)
+ , m_templateCount(0)
+#endif
{
}
@@ -199,19 +202,37 @@
}
}
- if (m_token.type() != HTMLTokenTypes::StartTag)
+ if (m_token.type() != HTMLTokenTypes::StartTag) {
+#if ENABLE(TEMPLATE_ELEMENT)
+ if (m_templateCount && m_token.type() == HTMLTokenTypes::EndTag && AtomicString(m_token.name().data()) == templateTag)
+ m_templateCount--;
+#endif
return;
+ }
PreloadTask task(m_token);
m_tokenizer->updateStateFor(task.tagName());
+#if ENABLE(TEMPLATE_ELEMENT)
+ if (task.tagName() == templateTag)
+ m_templateCount++;
+#endif
+
if (task.tagName() == styleTag)
m_inStyle = true;
if (task.tagName() == baseTag)
updatePredictedBaseElementURL(KURL(m_document->url(), task.baseElementHref()));
- task.preload(m_document, m_predictedBaseElementURL.isEmpty() ? m_document->baseURL() : m_predictedBaseElementURL);
+ bool preload = true;
+
+#if ENABLE(TEMPLATE_ELEMENT)
+ if (m_templateCount)
+ preload = false;
+#endif
+
+ if (preload)
+ task.preload(m_document, m_predictedBaseElementURL.isEmpty() ? m_document->baseURL() : m_predictedBaseElementURL);
}
void HTMLPreloadScanner::updatePredictedBaseElementURL(const KURL& baseElementURL)
Modified: trunk/Source/WebCore/html/parser/HTMLPreloadScanner.h (139501 => 139502)
--- trunk/Source/WebCore/html/parser/HTMLPreloadScanner.h 2013-01-11 22:42:45 UTC (rev 139501)
+++ trunk/Source/WebCore/html/parser/HTMLPreloadScanner.h 2013-01-11 22:45:35 UTC (rev 139502)
@@ -58,6 +58,10 @@
HTMLToken m_token;
bool m_inStyle;
KURL m_predictedBaseElementURL;
+
+#if ENABLE(TEMPLATE_ELEMENT)
+ size_t m_templateCount;
+#endif
};
}