Title: [206721] trunk
Revision
206721
Author
[email protected]
Date
2016-10-02 12:22:18 -0700 (Sun, 02 Oct 2016)

Log Message

Media controls for Soundcloud easily falls out of sync with what's actually playing
https://bugs.webkit.org/show_bug.cgi?id=162843
<rdar://problem/28176874>

Reviewed by Beth Dakin.

Source/WebCore:

Currently, audio elements are subject to the same main content restrictions as video elements. This is
problematic on sites where audio elements are really the main content, such as soundcloud. We need a different
heuristic for determining whether audio elements such as these should be allowed to show playback controls.

Furthermore, we currently forbid autoplaying audio from showing controls if it has user gesture restrictions
(i.e. it started playing via script). This is, again, problematic on sites where audio elements are played one
after another (such as on soundcloud). Even though a subsequent audio element may have been triggered via
script, we might want still want to show controls for it if the user has explicitly triggered other elements on
the page to begin playing. However, if the user has not gestured on any media in the page, we still should not
show controls for audio elements that begin playing via script.

Adds two new unit tests to TestWebKitAPI simulating audio playback behavior on soundcloud.

* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::removeBehaviorRestriction):
(WebCore::MediaElementSession::canShowControlsManager):
(WebCore::MediaElementSession::allowsPlaybackControlsForAutoplayingAudio):
* html/MediaElementSession.h:
* page/Page.h:
(WebCore::Page::allowsPlaybackControlsForAutoplayingAudio):
(WebCore::Page::setAllowsPlaybackControlsForAutoplayingAudio):

Tools:

Adds two new tests simulating audio playback behavior on soundcloud. Also tweaks some of the WKWebView test
message handling logic to support having multiple message-handler mappings.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/play-audio-on-click.html: Added.
* TestWebKitAPI/mac/TestWKWebViewMac.h:
* TestWebKitAPI/mac/TestWKWebViewMac.mm:
(-[TestMessageHandler addMessage:withHandler:]):
(-[TestMessageHandler userContentController:didReceiveScriptMessage:]):
(-[TestWKWebView performAfterReceivingMessage:action:]):
(-[TestWKWebView performAfterLoading:]):
(-[TestMessageHandler initWithMessage:handler:]): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206720 => 206721)


--- trunk/Source/WebCore/ChangeLog	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Source/WebCore/ChangeLog	2016-10-02 19:22:18 UTC (rev 206721)
@@ -1,3 +1,33 @@
+2016-10-02  Wenson Hsieh  <[email protected]>
+
+        Media controls for Soundcloud easily falls out of sync with what's actually playing
+        https://bugs.webkit.org/show_bug.cgi?id=162843
+        <rdar://problem/28176874>
+
+        Reviewed by Beth Dakin.
+
+        Currently, audio elements are subject to the same main content restrictions as video elements. This is
+        problematic on sites where audio elements are really the main content, such as soundcloud. We need a different
+        heuristic for determining whether audio elements such as these should be allowed to show playback controls.
+
+        Furthermore, we currently forbid autoplaying audio from showing controls if it has user gesture restrictions
+        (i.e. it started playing via script). This is, again, problematic on sites where audio elements are played one
+        after another (such as on soundcloud). Even though a subsequent audio element may have been triggered via
+        script, we might want still want to show controls for it if the user has explicitly triggered other elements on
+        the page to begin playing. However, if the user has not gestured on any media in the page, we still should not
+        show controls for audio elements that begin playing via script.
+
+        Adds two new unit tests to TestWebKitAPI simulating audio playback behavior on soundcloud.
+
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::removeBehaviorRestriction):
+        (WebCore::MediaElementSession::canShowControlsManager):
+        (WebCore::MediaElementSession::allowsPlaybackControlsForAutoplayingAudio):
+        * html/MediaElementSession.h:
+        * page/Page.h:
+        (WebCore::Page::allowsPlaybackControlsForAutoplayingAudio):
+        (WebCore::Page::setAllowsPlaybackControlsForAutoplayingAudio):
+
 2016-10-02  Ryan Haddad  <[email protected]>
 
         Unreviewed, rolling out r206683.

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (206720 => 206721)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2016-10-02 19:22:18 UTC (rev 206721)
@@ -138,8 +138,11 @@
 
 void MediaElementSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
 {
-    if (restriction & RequireUserGestureToControlControlsManager)
+    if (restriction & RequireUserGestureToControlControlsManager) {
         m_mostRecentUserInteractionTime = monotonicallyIncreasingTime();
+        if (auto page = m_element.document().page())
+            page->setAllowsPlaybackControlsForAutoplayingAudio(true);
+    }
 
     LOG(Media, "MediaElementSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data());
     m_restrictions &= ~restriction;
@@ -228,6 +231,31 @@
         return true;
     }
 
+    if (m_element.muted()) {
+        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Muted");
+        return false;
+    }
+
+    if (m_element.document().isMediaDocument()) {
+        LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document");
+        return true;
+    }
+
+    if (client().presentationType() == Audio) {
+        if (!hasBehaviorRestriction(RequireUserGestureToControlControlsManager) || ScriptController::processingUserGestureForMedia()) {
+            LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Audio element with user gesture");
+            return true;
+        }
+
+        if (m_element.isPlaying() && allowsPlaybackControlsForAutoplayingAudio()) {
+            LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: User has played media before");
+            return true;
+        }
+
+        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Audio element is not suitable");
+        return false;
+    }
+
     if (purpose == PlaybackControlsPurpose::ControlsManager && !isElementRectMostlyInMainFrame(m_element)) {
         LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Not in main frame");
         return false;
@@ -238,11 +266,6 @@
         return false;
     }
 
-    if (m_element.document().isMediaDocument()) {
-        LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document");
-        return true;
-    }
-
     if (m_element.document().activeDOMObjectsAreSuspended()) {
         LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: activeDOMObjectsAreSuspended()");
         return false;
@@ -263,11 +286,6 @@
         return false;
     }
 
-    if (m_element.muted()) {
-        LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Muted");
-        return false;
-    }
-
     if (!m_element.hasEverNotifiedAboutPlaying()) {
         LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Hasn't fired playing notification");
         return false;
@@ -739,6 +757,12 @@
     return page && !page->isVisibleAndActive();
 }
 
+bool MediaElementSession::allowsPlaybackControlsForAutoplayingAudio() const
+{
+    auto page = m_element.document().page();
+    return page && page->allowsPlaybackControlsForAutoplayingAudio();
 }
 
+}
+
 #endif // ENABLE(VIDEO)

Modified: trunk/Source/WebCore/html/MediaElementSession.h (206720 => 206721)


--- trunk/Source/WebCore/html/MediaElementSession.h	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Source/WebCore/html/MediaElementSession.h	2016-10-02 19:22:18 UTC (rev 206721)
@@ -124,6 +124,8 @@
     bool isLargeEnoughForMainContent(MediaSessionMainContentPurpose) const;
     double mostRecentUserInteractionTime() const;
 
+    bool allowsPlaybackControlsForAutoplayingAudio() const;
+
 private:
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)

Modified: trunk/Source/WebCore/page/Page.h (206720 => 206721)


--- trunk/Source/WebCore/page/Page.h	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Source/WebCore/page/Page.h	2016-10-02 19:22:18 UTC (rev 206721)
@@ -511,6 +511,9 @@
     WEBCORE_EXPORT void setAllowsMediaDocumentInlinePlayback(bool);
 #endif
 
+    bool allowsPlaybackControlsForAutoplayingAudio() const { return m_allowsPlaybackControlsForAutoplayingAudio; }
+    void setAllowsPlaybackControlsForAutoplayingAudio(bool allowsPlaybackControlsForAutoplayingAudio) { m_allowsPlaybackControlsForAutoplayingAudio = allowsPlaybackControlsForAutoplayingAudio; }
+
 #if ENABLE(INDEXED_DATABASE)
     IDBClient::IDBConnectionToServer& idbConnection();
 #endif
@@ -719,6 +722,7 @@
     MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
     
     bool m_allowsMediaDocumentInlinePlayback { false };
+    bool m_allowsPlaybackControlsForAutoplayingAudio { false };
     bool m_showAllPlugins { false };
     bool m_controlledByAutomation { false };
     bool m_resourceCachingDisabled { false };

Modified: trunk/Tools/ChangeLog (206720 => 206721)


--- trunk/Tools/ChangeLog	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Tools/ChangeLog	2016-10-02 19:22:18 UTC (rev 206721)
@@ -1,3 +1,26 @@
+2016-10-02  Wenson Hsieh  <[email protected]>
+
+        Media controls for Soundcloud easily falls out of sync with what's actually playing
+        https://bugs.webkit.org/show_bug.cgi?id=162843
+        <rdar://problem/28176874>
+
+        Reviewed by Beth Dakin.
+
+        Adds two new tests simulating audio playback behavior on soundcloud. Also tweaks some of the WKWebView test
+        message handling logic to support having multiple message-handler mappings.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/play-audio-on-click.html: Added.
+        * TestWebKitAPI/mac/TestWKWebViewMac.h:
+        * TestWebKitAPI/mac/TestWKWebViewMac.mm:
+        (-[TestMessageHandler addMessage:withHandler:]):
+        (-[TestMessageHandler userContentController:didReceiveScriptMessage:]):
+        (-[TestWKWebView performAfterReceivingMessage:action:]):
+        (-[TestWKWebView performAfterLoading:]):
+        (-[TestMessageHandler initWithMessage:handler:]): Deleted.
+
 2016-09-30  Alex Christensen  <[email protected]>
 
         Fix off-by-one error in URLParser::parseIPv4Host

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (206720 => 206721)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-10-02 19:22:18 UTC (rev 206721)
@@ -479,6 +479,7 @@
 		CEBABD491B71687C0051210A /* should-open-external-schemes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBABD481B71687C0051210A /* should-open-external-schemes.html */; };
 		E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
 		E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
+		F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
 		F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
 		F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
 		F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
@@ -552,6 +553,7 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
 				F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
 				837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */,
 				2E9896151D8F093800739892 /* text-and-password-inputs.html in Copy Resources */,
@@ -1195,6 +1197,7 @@
 		E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Deque.cpp; sourceTree = "<group>"; };
 		E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
 		F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		F415086C1DA040C10044BE9B /* play-audio-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "play-audio-on-click.html"; sourceTree = "<group>"; };
 		F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKit2Cocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; };
 		F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
 		F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
@@ -1493,6 +1496,7 @@
 		A16F66B81C40E9E100BD4D24 /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				F415086C1DA040C10044BE9B /* play-audio-on-click.html */,
 				F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */,
 				2E9896141D8F092B00739892 /* text-and-password-inputs.html */,
 				2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */,

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (206720 => 206721)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2016-10-02 19:22:18 UTC (rev 206721)
@@ -313,6 +313,42 @@
     [webView expectControlsManager:NO afterReceivingMessage:@"playing"];
 }
 
+TEST(VideoControlsManager, VideoControlsManagerAudioElementStartedByInteraction)
+{
+    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 400, 400));
+
+    [webView loadTestPageNamed:@"play-audio-on-click"];
+    [webView waitForPageToLoadWithAutoplayingVideos:0];
+    [webView mouseDownAtPoint:NSMakePoint(200, 200) simulatePressure:YES];
+
+    // An audio element MUST be started with a user gesture in order to have a controls manager, so the expectation is YES.
+    [webView expectControlsManager:YES afterReceivingMessage:@"playing-first"];
+    EXPECT_TRUE([[webView controlledElementID] isEqualToString:@"first"]);
+}
+
+TEST(VideoControlsManager, VideoControlsManagerAudioElementFollowingUserInteraction)
+{
+    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 400, 400));
+
+    [webView loadTestPageNamed:@"play-audio-on-click"];
+    [webView waitForPageToLoadWithAutoplayingVideos:0];
+    [webView mouseDownAtPoint:NSMakePoint(200, 200) simulatePressure:YES];
+
+    [webView performAfterReceivingMessage:@"playing-first" action:^ {
+        [webView evaluateJavaScript:@"seekToEnd()" completionHandler:nil];
+    }];
+
+    __block bool secondAudioPlaying = false;
+    [webView performAfterReceivingMessage:@"playing-second" action:^ {
+        secondAudioPlaying = true;
+    }];
+    TestWebKitAPI::Util::run(&secondAudioPlaying);
+    while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
+        if ([webView _hasActiveVideoForControlsManager] && [[webView controlledElementID] isEqualToString:@"second"])
+            break;
+    }
+}
+
 TEST(VideoControlsManager, VideoControlsManagerTearsDownMediaControlsOnDealloc)
 {
     RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100));

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/play-audio-on-click.html (0 => 206721)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/play-audio-on-click.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/play-audio-on-click.html	2016-10-02 19:22:18 UTC (rev 206721)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        div {
+            width: 400px;
+            height: 400px;
+            background-color: red;
+        }
+        body {
+            margin: 0;
+        }
+    </style>
+    <script>
+        var audio;
+
+        function playFirstTrack()
+        {
+            audio = document.createElement("audio");
+            audio.src = ""
+            audio.id = "first";
+            audio._onplaying_ = audioPlayingHandler("first");
+            audio._onended_ = playSecondTrack;
+            audio.play();
+        }
+
+        function playSecondTrack()
+        {
+            audio = document.createElement("audio");
+            audio.src = ""
+            audio.id = "second";
+            audio._onplaying_ = audioPlayingHandler("second");
+            audio.play();
+        }
+
+        function seekToEnd()
+        {
+            audio.currentTime = audio.duration - 0.5;
+        }
+
+        function audioPlayingHandler(id)
+        {
+            return function() {
+                try {
+                    window.webkit.messageHandlers.testHandler.postMessage("playing-" + id);
+                } catch(e) {}
+            }
+        }
+    </script>
+</head>
+<body>
+    <div _onmousedown_=playFirstTrack()>Click me to start playing!</div>
+</body>
+</html>

Modified: trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h (206720 => 206721)


--- trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h	2016-10-02 19:22:18 UTC (rev 206721)
@@ -31,7 +31,7 @@
 #if WK_API_ENABLED && PLATFORM(MAC)
 
 @interface TestMessageHandler : NSObject <WKScriptMessageHandler>
-- (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler;
+- (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler;
 @end
 
 @interface TestWKWebView : WKWebView

Modified: trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm (206720 => 206721)


--- trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm	2016-10-02 19:19:29 UTC (rev 206720)
+++ trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm	2016-10-02 19:22:18 UTC (rev 206721)
@@ -37,25 +37,22 @@
 #import <wtf/RetainPtr.h>
 
 @implementation TestMessageHandler {
-    dispatch_block_t _handler;
-    NSString *_message;
+    NSMutableDictionary<NSString *, dispatch_block_t> *_messageHandlers;
 }
 
-- (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler
+- (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler
 {
-    if (!(self = [super init]))
-        return nil;
+    if (!_messageHandlers)
+        _messageHandlers = [NSMutableDictionary dictionary];
 
-    _handler = [handler copy];
-    _message = message;
-
-    return self;
+    _messageHandlers[message] = [handler copy];
 }
 
 - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
 {
-    if ([(NSString *)[message body] isEqualToString:_message] && _handler)
-        _handler();
+    dispatch_block_t handler = _messageHandlers[message.body];
+    if (handler)
+        handler();
 }
 
 @end
@@ -140,6 +137,7 @@
 
 @implementation TestWKWebView {
     TestWKWebViewHostWindow *_hostWindow;
+    RetainPtr<TestMessageHandler> _testHandler;
 }
 
 - (instancetype)initWithFrame:(CGRect)frame
@@ -172,10 +170,12 @@
 
 - (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action
 {
-    RetainPtr<TestMessageHandler> handler = adoptNS([[TestMessageHandler alloc] initWithMessage:message handler:action]);
-    WKUserContentController* contentController = [[self configuration] userContentController];
-    [contentController removeScriptMessageHandlerForName:@"testHandler"];
-    [contentController addScriptMessageHandler:handler.get() name:@"testHandler"];
+    if (!_testHandler) {
+        _testHandler = adoptNS([[TestMessageHandler alloc] init]);
+        [[[self configuration] userContentController] addScriptMessageHandler:_testHandler.get() name:@"testHandler"];
+    }
+
+    [_testHandler addMessage:message withHandler:action];
 }
 
 - (void)loadTestPageNamed:(NSString *)pageName
@@ -223,7 +223,9 @@
 }
 
 - (void)performAfterLoading:(dispatch_block_t)actions {
-    TestMessageHandler *handler = [[TestMessageHandler alloc] initWithMessage:@"loaded" handler:actions];
+    TestMessageHandler *handler = [[TestMessageHandler alloc] init];
+    [handler addMessage:@"loaded" withHandler:actions];
+
     NSString *_onloadScript_ = @"window._onload_ = () => window.webkit.messageHandlers.onloadHandler.postMessage('loaded')";
     WKUserScript *script = [[WKUserScript alloc] initWithSource:onloadScript injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to