Video element image loader must persist after element detach.
authortsepez@chromium.org <tsepez@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 17:57:58 +0000 (17:57 +0000)
committertsepez@chromium.org <tsepez@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 17:57:58 +0000 (17:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90801

Reviewed by Eric Carlson.

We rely on the OwnPtr in the element to cleanup the loader.

Source/WebCore:

Test: fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html

* html/HTMLVideoElement.cpp:
(WebCore):
* html/HTMLVideoElement.h:
(HTMLVideoElement):

LayoutTests:

* fast/dom/beforeload/remove-video-poster-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125052 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/beforeload/remove-video-poster-in-beforeload-listener-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/HTMLVideoElement.h

index 083b3fe..2949672 100644 (file)
@@ -1,3 +1,15 @@
+2012-08-08  Tom Sepez  <tsepez@chromium.org>
+
+        Video element image loader must persist after element detach.  
+        https://bugs.webkit.org/show_bug.cgi?id=90801
+
+        Reviewed by Eric Carlson.
+
+        We rely on the OwnPtr in the element to cleanup the loader.     
+
+        * fast/dom/beforeload/remove-video-poster-in-beforeload-listener-expected.txt: Added.
+        * fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html: Added.
+
 2012-08-08  Dan Bernstein  <mitz@apple.com>
 
         REGRESSION (r123171): <svg> element with intrinsic size and max-width gets sized incorrectly
diff --git a/LayoutTests/fast/dom/beforeload/remove-video-poster-in-beforeload-listener-expected.txt b/LayoutTests/fast/dom/beforeload/remove-video-poster-in-beforeload-listener-expected.txt
new file mode 100644 (file)
index 0000000..9b5538a
--- /dev/null
@@ -0,0 +1,3 @@
+This page tests that you can correctly remove a video object with a poster in a beforeload listener without causing a crash.
+
+PASS
diff --git a/LayoutTests/fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html b/LayoutTests/fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html
new file mode 100644 (file)
index 0000000..48b298b
--- /dev/null
@@ -0,0 +1,46 @@
+<html>
+<head>
+    <script src="resources/print.js"></script>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+        
+        var count = 0;
+        var maxCount = 10;
+        var timeout = 100;
+
+        document.addEventListener("beforeload", function(event) {
+            event.target.parentElement.removeChild(event.target);
+        }, true);
+    </script>
+</head>
+<body>
+    <p>This page tests that you can correctly remove a video object with a poster in a beforeload listener without causing a crash.</p>
+    <div id="console"></div>
+    <script>
+        function checkObjectRemoval()
+        {
+            if (!document.getElementsByTagName("video").length) {
+                print("PASS", "green");
+                if (window.testRunner)
+                    testRunner.notifyDone();
+                return;
+            }
+            
+            if (++count > maxCount) {
+                print("FAIL", "red");
+                if (window.testRunner)
+                    testRunner.notifyDone();
+                return;
+            }
+            
+            setTimeout("checkObjectRemoval()", timeout);
+        }
+        
+        setTimeout("checkObjectRemoval()", timeout);
+    </script>
+    <video poster="../resources/abe.png">>><source>>>
+</body>
+</html>
index ad55da4..cd0cb11 100644 (file)
@@ -1,3 +1,19 @@
+2012-08-08  Tom Sepez  <tsepez@chromium.org>
+
+        Video element image loader must persist after element detach.  
+        https://bugs.webkit.org/show_bug.cgi?id=90801
+
+        Reviewed by Eric Carlson.
+
+        We rely on the OwnPtr in the element to cleanup the loader.     
+
+        Test: fast/dom/beforeload/remove-video-poster-in-beforeload-listener.html
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore):
+        * html/HTMLVideoElement.h:
+        (HTMLVideoElement):
+
 2012-08-08  Nikhil Bhargava  <nbhargava@google.com>
 
         Improve RenderObject.h compile time - split CachedImage and CachedImageClient
index eebe533..0e0e22f 100644 (file)
@@ -87,14 +87,6 @@ void HTMLVideoElement::attach()
 #endif
 }
 
-void HTMLVideoElement::detach()
-{
-    HTMLMediaElement::detach();
-    
-    if (!shouldDisplayPosterImage() && m_imageLoader)
-        m_imageLoader.clear();
-}
-
 void HTMLVideoElement::collectStyleForAttribute(const Attribute& attribute, StylePropertySet* style)
 {
     if (attribute.name() == widthAttr)
index b4c0391..dbe52a4 100644 (file)
@@ -75,7 +75,6 @@ private:
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 #endif
     virtual void attach();
-    virtual void detach();
     virtual void parseAttribute(const Attribute&) OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForAttribute(const Attribute&, StylePropertySet*) OVERRIDE;