Title: [87691] trunk
Revision
87691
Author
aba...@webkit.org
Date
2011-05-30 10:05:37 -0700 (Mon, 30 May 2011)

Log Message

2011-05-30  Gavin Peters  <gav...@chromium.org>

        Reviewed by Adam Barth.

        prevent HTMLLinkElement from watching multiple CachedResources
        https://bugs.webkit.org/show_bug.cgi?id=61686

        If we modify an existing link element, stop listening to the previous
        cached resource, to prevent double notifications (which crash).

        Test: fast/dom/HTMLLinkElement/prefetch-too-many-clients.html

        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::process):
2011-05-30  Gavin Peters  <gav...@chromium.org>

        Reviewed by Adam Barth.

        prevent HTMLLinkElement from watching multiple CachedResources
        https://bugs.webkit.org/show_bug.cgi?id=61686

        If we modify an existing link element, stop listening to the previous
        cached resource, to prevent double notifications (which crash).

        * fast/dom/HTMLLinkElement/prefetch-too-many-clients-expected.txt: Added.
        * fast/dom/HTMLLinkElement/prefetch-too-many-clients.html: Added.
        * platform/gtk/Skipped:
        * platform/mac/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87690 => 87691)


--- trunk/LayoutTests/ChangeLog	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/LayoutTests/ChangeLog	2011-05-30 17:05:37 UTC (rev 87691)
@@ -1,3 +1,20 @@
+2011-05-30  Gavin Peters  <gav...@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        prevent HTMLLinkElement from watching multiple CachedResources
+        https://bugs.webkit.org/show_bug.cgi?id=61686
+
+        If we modify an existing link element, stop listening to the previous
+        cached resource, to prevent double notifications (which crash).
+
+        * fast/dom/HTMLLinkElement/prefetch-too-many-clients-expected.txt: Added.
+        * fast/dom/HTMLLinkElement/prefetch-too-many-clients.html: Added.
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+
 2011-05-30  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r87683.

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-too-many-clients-expected.txt (0 => 87691)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-too-many-clients-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-too-many-clients-expected.txt	2011-05-30 17:05:37 UTC (rev 87691)
@@ -0,0 +1,2 @@
+PASS we didn't crash.
+This test makes sure that a single prefetch element is not a client of multiple cachedresources at the same time; by repeatedly changing an existing link element, we will induce a double-notify bug if that element is not releasing its cachedresource on update.

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-too-many-clients.html (0 => 87691)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-too-many-clients.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/prefetch-too-many-clients.html	2011-05-30 17:05:37 UTC (rev 87691)
@@ -0,0 +1,38 @@
+<html>
+<body _onload_="many_link_updates(50);setTimeout('done();',0)">
+<div id="console"></div>
+<script src=""
+<script>
+
+function addLink(url, rel) {
+    var link = document.getElementById(rel) ||
+               document.createElement('link');
+    link.id = rel;
+    link.rel = rel;
+    link.href = ""
+    document.body.appendChild(link);
+}
+
+function many_link_updates(iter) {
+    for(var i=0;i<iter;++i) {
+        addLink("many_link_updates_" + i + ".html", "prefetch");
+    }
+}
+
+function done() {
+    testPassed("we didn't crash.");
+    if (window.layoutTestController) {
+        layoutTestController.notifyDone();
+    }
+}
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone(); 
+    layoutTestController.dumpAsText();
+}
+</script>
+<p>This test makes sure that a single prefetch element is not a client of multiple cachedresources at the same time; by 
+repeatedly changing an existing link element, we will induce a double-notify bug if that element is not releasing its
+cachedresource on update.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/gtk/Skipped (87690 => 87691)


--- trunk/LayoutTests/platform/gtk/Skipped	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/LayoutTests/platform/gtk/Skipped	2011-05-30 17:05:37 UTC (rev 87691)
@@ -972,9 +972,10 @@
 # Link prefetch is disabled by default
 fast/dom/HTMLLinkElement/link-and-subresource-test.html
 fast/dom/HTMLLinkElement/prefetch.html
+fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
-fast/dom/HTMLLinkElement/prefetch-beforeload.html
+fast/dom/HTMLLinkElement/prefetch-too-many-clients.html
 fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
 

Modified: trunk/LayoutTests/platform/mac/Skipped (87690 => 87691)


--- trunk/LayoutTests/platform/mac/Skipped	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/LayoutTests/platform/mac/Skipped	2011-05-30 17:05:37 UTC (rev 87691)
@@ -182,6 +182,7 @@
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/prefetch-too-many-clients.html
 fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
 http/tests/misc/link-rel-prefetch-and-subresource.html

Modified: trunk/LayoutTests/platform/qt/Skipped (87690 => 87691)


--- trunk/LayoutTests/platform/qt/Skipped	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/LayoutTests/platform/qt/Skipped	2011-05-30 17:05:37 UTC (rev 87691)
@@ -1948,6 +1948,7 @@
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/prefetch-too-many-clients.html
 fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html
 http/tests/misc/link-rel-prefetch-and-subresource.html

Modified: trunk/LayoutTests/platform/win/Skipped (87690 => 87691)


--- trunk/LayoutTests/platform/win/Skipped	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/LayoutTests/platform/win/Skipped	2011-05-30 17:05:37 UTC (rev 87691)
@@ -1007,6 +1007,7 @@
 fast/dom/HTMLLinkElement/prefetch-beforeload.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
 fast/dom/HTMLLinkElement/prefetch-onload.html
+fast/dom/HTMLLinkElement/prefetch-too-many-clients.html
 http/tests/misc/link-rel-prefetch-and-subresource.html
 fast/dom/HTMLLinkElement/prerender.html
 fast/dom/HTMLLinkElement/subresource.html

Modified: trunk/Source/WebCore/ChangeLog (87690 => 87691)


--- trunk/Source/WebCore/ChangeLog	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/Source/WebCore/ChangeLog	2011-05-30 17:05:37 UTC (rev 87691)
@@ -1,3 +1,18 @@
+2011-05-30  Gavin Peters  <gav...@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        prevent HTMLLinkElement from watching multiple CachedResources
+        https://bugs.webkit.org/show_bug.cgi?id=61686
+
+        If we modify an existing link element, stop listening to the previous
+        cached resource, to prevent double notifications (which crash).
+
+        Test: fast/dom/HTMLLinkElement/prefetch-too-many-clients.html
+
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+
 2011-05-30  Peter Varga  <pva...@webkit.org>
 
         Unreviewed build fix.

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (87690 => 87691)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2011-05-30 16:25:06 UTC (rev 87690)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2011-05-30 17:05:37 UTC (rev 87691)
@@ -266,6 +266,11 @@
             type = CachedResource::LinkPrerender;
 
         ResourceRequest linkRequest(document()->completeURL(m_url));
+        
+        if (m_cachedLinkResource) {
+            m_cachedLinkResource->removeClient(this);
+            m_cachedLinkResource = 0;
+        }
         m_cachedLinkResource = document()->cachedResourceLoader()->requestLinkResource(type, linkRequest, priority);
         if (m_cachedLinkResource)
             m_cachedLinkResource->addClient(this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to