Title: [122683] trunk
Revision
122683
Author
[email protected]
Date
2012-07-15 14:26:51 -0700 (Sun, 15 Jul 2012)

Log Message

Windowless WebView not firing _javascript_ load event if there is a media element
https://bugs.webkit.org/show_bug.cgi?id=91331

Reviewed by Eric Carlson.

Source/WebCore:

In prepareForLoad we start deferring the load event. If we fall into this
clause where the page can not start loading media we bail, potentially
indefinitely waiting until we can start loading media. Since we can not
be certain this will ever happen, we should stop deferring the page's
load event.

Test: WebKit1.WindowlessWebViewWithMedia TestWebKitAPI test. The only
way this path was reachable right now is on the mac port.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::loadInternal):

Tools:

Test a windowless WebView loading a page with a media element. The load
event should happen on the next spin of the run loop, but we spin check
the page, with a timeout of 250ms.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.html: Added.
* TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm: Added.
(-[WindowlessWebViewWithMediaFrameLoadDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::spinLoop): Spin check with timeout. Runs a block each spin to early bail.
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122682 => 122683)


--- trunk/Source/WebCore/ChangeLog	2012-07-15 20:24:03 UTC (rev 122682)
+++ trunk/Source/WebCore/ChangeLog	2012-07-15 21:26:51 UTC (rev 122683)
@@ -1,3 +1,22 @@
+2012-07-15  Joseph Pecoraro  <[email protected]>
+
+        Windowless WebView not firing _javascript_ load event if there is a media element
+        https://bugs.webkit.org/show_bug.cgi?id=91331
+
+        Reviewed by Eric Carlson.
+
+        In prepareForLoad we start deferring the load event. If we fall into this
+        clause where the page can not start loading media we bail, potentially
+        indefinitely waiting until we can start loading media. Since we can not
+        be certain this will ever happen, we should stop deferring the page's
+        load event.
+
+        Test: WebKit1.WindowlessWebViewWithMedia TestWebKitAPI test. The only
+        way this path was reachable right now is on the mac port.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::loadInternal):
+
 2012-07-15  Dan Bernstein  <[email protected]>
 
         <rdar://problem/11875795> REGRESSION (tiled drawing): Page’s scroll bars flash with each character you type in a textarea (affects Wikipedia and YouTube)

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (122682 => 122683)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-07-15 20:24:03 UTC (rev 122682)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-07-15 21:26:51 UTC (rev 122683)
@@ -759,6 +759,7 @@
     // If we can't start a load right away, start it later.
     Page* page = document()->page();
     if (pageConsentRequiredForLoad() && page && !page->canStartMedia()) {
+        setShouldDelayLoadEvent(false);
         if (m_isWaitingUntilMediaCanStart)
             return;
         document()->addMediaCanStartListener(this);

Modified: trunk/Tools/ChangeLog (122682 => 122683)


--- trunk/Tools/ChangeLog	2012-07-15 20:24:03 UTC (rev 122682)
+++ trunk/Tools/ChangeLog	2012-07-15 21:26:51 UTC (rev 122683)
@@ -1,3 +1,21 @@
+2012-07-15  Joseph Pecoraro  <[email protected]>
+
+        Windowless WebView not firing _javascript_ load event if there is a media element
+        https://bugs.webkit.org/show_bug.cgi?id=91331
+
+        Reviewed by Eric Carlson.
+
+        Test a windowless WebView loading a page with a media element. The load
+        event should happen on the next spin of the run loop, but we spin check
+        the page, with a timeout of 250ms.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.html: Added.
+        * TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm: Added.
+        (-[WindowlessWebViewWithMediaFrameLoadDelegate webView:didFinishLoadForFrame:]):
+        (TestWebKitAPI::spinLoop): Spin check with timeout. Runs a block each spin to early bail.
+        (TestWebKitAPI::TEST):
+
 2012-07-14  Benjamin Poulain  <[email protected]>
 
         [Mac] Do not try to update the cache model for every WebPreferences change

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (122682 => 122683)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-07-15 20:24:03 UTC (rev 122682)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-07-15 21:26:51 UTC (rev 122683)
@@ -79,6 +79,8 @@
 		9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
 		9B4F8FA4159D52B1002D9F94 /* HTMLCollectionNamedItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */; };
 		9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
+		A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */; };
+		A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
 		A7A966DB140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */; };
 		B55F11A01516834F00915916 /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = B55F119F1516834F00915916 /* AttributedString.mm */; };
 		B55F11B71517D03300915916 /* attributedStringCustomFont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = B55F11B01517A2C400915916 /* attributedStringCustomFont.html */; };
@@ -203,6 +205,7 @@
 				9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */,
 				E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */,
 				517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */,
+				A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */,
 				379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
 				33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */,
 				1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
@@ -302,6 +305,8 @@
 		9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormCollectionNamedItem.html; sourceTree = "<group>"; };
 		9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
 		9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; };
+		A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WindowlessWebViewWithMedia.html; sourceTree = "<group>"; };
+		A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowlessWebViewWithMedia.mm; sourceTree = "<group>"; };
 		A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CheckedArithmeticOperations.cpp; path = WTF/CheckedArithmeticOperations.cpp; sourceTree = "<group>"; };
 		B55F119F1516834F00915916 /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };
 		B55F11B01517A2C400915916 /* attributedStringCustomFont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = attributedStringCustomFont.html; sourceTree = "<group>"; };
@@ -704,6 +709,7 @@
 				37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */,
 				E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
 				51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
+				A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -724,6 +730,7 @@
 				517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */,
 				C07E6CB113FD738A0038B22B /* devicePixelRatio.html */,
 				C540F783152E5A7800A40C8C /* verboseMarkup.html */,
+				A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -937,6 +944,7 @@
 				F660AA1315A619C9003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
 				0F17BBD615AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */,
 				261516D615B0E60500A2C201 /* SetAndUpdateCacheModel.mm in Sources */,
+				A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.html (0 => 122683)


--- trunk/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.html	2012-07-15 21:26:51 UTC (rev 122683)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+    We want to make sure the page sends its onload event even if it has media in a windowless WebView.
+    <audio src=""
+    <script>
+    var didTriggerLoad = false;
+    window.addEventListener('load', function(event) {
+        didTriggerLoad = true;
+    }, false);
+    </script>
+</body>
+</html>

Added: trunk/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm (0 => 122683)


--- trunk/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WindowlessWebViewWithMedia.mm	2012-07-15 21:26:51 UTC (rev 122683)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "_javascript_Test.h"
+#include "PlatformUtilities.h"
+#include <wtf/RetainPtr.h>
+
+
+static bool didFinishLoad;
+
+@interface WindowlessWebViewWithMediaFrameLoadDelegate : NSObject
+@end
+
+@implementation WindowlessWebViewWithMediaFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+
+@end
+
+
+namespace TestWebKitAPI {
+
+static void spinLoop(NSTimeInterval timeout, BOOL (^block)())
+{
+    if (timeout <= 0)
+        return;
+
+    NSTimeInterval end = [[NSDate date] timeIntervalSinceReferenceDate] + timeout;
+    NSDate *endDate = [NSDate dateWithTimeIntervalSinceReferenceDate:end];
+
+    while (!block()) {
+        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];
+        if ([[NSDate date] timeIntervalSinceReferenceDate] > end)
+            break;
+    }
+}
+
+TEST(WebKit1, WindowlessWebViewWithMedia)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+    RetainPtr<WindowlessWebViewWithMediaFrameLoadDelegate> testController(AdoptNS, [WindowlessWebViewWithMediaFrameLoadDelegate new]);
+    webView.get().frameLoadDelegate = testController.get();
+    [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"WindowlessWebViewWithMedia" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+    EXPECT_EQ(nil, [webView.get() window]);
+
+    Util::run(&didFinishLoad);    
+
+    spinLoop(0.25, ^{
+        return [[webView.get() stringByEvaluatingJavaScriptFromString:@"window.didTriggerLoad"] isEqualToString:@"true"];
+    });
+
+    EXPECT_JS_EQ(webView.get(), "window.didTriggerLoad", "true");
+
+    [pool drain];
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to