WebKit Bugzilla
Attachment 357608 Details for
Bug 186856
: [Fullscreen] Suspend page (and pause video) while phishing warining is presented
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186856-20181218135005.patch (text/plain), 36.58 KB, created by
Jer Noble
on 2018-12-18 13:50:06 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jer Noble
Created:
2018-12-18 13:50:06 PST
Size:
36.58 KB
patch
obsolete
>Subversion Revision: 238907 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 846de468f84fc60e7aff21245032f03239cce8b2..b5e38a05c4606e676bba204054ec0d57649ca433 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,51 @@ >+2018-12-18 Jer Noble <jer.noble@apple.com> >+ >+ [Fullscreen] Suspend page (and pause video) while phishing warining is presented >+ https://bugs.webkit.org/show_bug.cgi?id=186856 >+ <rdar://problem/41212444> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ New API tests: >+ WebKitLegacy.ScrollingDoesNotPauseMedia >+ WKWebView.StopAllMediaPlayback >+ WKWebView.SuspendResumeAllMediaPlayback >+ >+ Do not use suspendActiveDOMObjects(ReasonForSuspension::PageWillBeSuspended) to pause >+ video. Roll back the changes to HTMLMediaElement, and introduce a new set of Page calls >+ suspendAllMediaPlayback() & resumeAllMediaPlayback() which replaces the removed bahavior. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::~Document): >+ (WebCore::Document::stopAllMediaPlayback): >+ (WebCore::Document::suspendAllMediaPlayback): >+ (WebCore::Document::resumeAllMediaPlayback): >+ * dom/Document.h: >+ * html/HTMLMediaElement.cpp: >+ (WebCore::HTMLMediaElement::HTMLMediaElement): >+ (WebCore::HTMLMediaElement::parseAttribute): >+ (WebCore::HTMLMediaElement::didFinishInsertingNode): >+ (WebCore::HTMLMediaElement::setSrcObject): >+ (WebCore::HTMLMediaElement::updateActiveTextTrackCues): >+ (WebCore::HTMLMediaElement::suspend): >+ (WebCore::HTMLMediaElement::resume): >+ (WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless const): >+ * html/HTMLMediaElement.h: >+ (WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless const): Deleted. >+ * html/MediaElementSession.cpp: >+ (WebCore::MediaElementSession::playbackPermitted const): >+ * page/Page.cpp: >+ (WebCore::Page::stopAllMediaPlayback): >+ (WebCore::Page::suspendAllMediaPlayback): >+ (WebCore::Page::resumeAllMediaPlayback): >+ * page/Page.h: >+ (WebCore::Page::mediaPlaybackIsSuspended): >+ * platform/audio/PlatformMediaSession.h: >+ * platform/audio/PlatformMediaSessionManager.cpp: >+ (WebCore::PlatformMediaSessionManager::suspendAllMediaPlaybackForDocument): >+ (WebCore::PlatformMediaSessionManager::resumeAllMediaPlaybackForDocument): >+ * platform/audio/PlatformMediaSessionManager.h: >+ > 2018-12-14 Jer Noble <jer.noble@apple.com> > > CRASH in CDMInstanceSessionFairPlayStreamingAVFObjC::closeSession(WTF::String const&, WTF::Function<void ()>&&) >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 9af22c9a1b827782b9852cae5af9d38b77f60849..e908d723f1ced27506f636678098b023a2018e48 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2018-12-18 Jer Noble <jer.noble@apple.com> >+ >+ [Fullscreen] Suspend page (and pause video) while phishing warining is presented >+ https://bugs.webkit.org/show_bug.cgi?id=186856 >+ <rdar://problem/41212444> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a new WebPage, WebPageProxy, & WKWebView SPI to stop, suspend, and resume all >+ existing media playback in the page. >+ >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _stopAllMediaPlayback]): >+ (-[WKWebView _suspendAllMediaPlayback]): >+ (-[WKWebView _resumeAllMediaPlayback]): >+ * UIProcess/API/Cocoa/WKWebViewPrivate.h: >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::stopAllMediaPlayback): >+ (WebKit::WebPageProxy::suspendAllMediaPlayback): >+ (WebKit::WebPageProxy::resumeAllMediaPlayback): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/ios/fullscreen/WKFullScreenViewController.mm: >+ (-[WKFullScreenViewController _showPhishingAlert]): >+ > 2018-12-03 Jer Noble <jer.noble@apple.com> > > Enable MediaCapabilities by default. >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index e334adbeaeb02add8a305829c9b6f2eeb4e5fae2..78b013ae3b34fd136a8208ba6474f3920229a5e2 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -652,8 +652,7 @@ Document::~Document() > m_cachedResourceLoader->setDocument(nullptr); > > #if ENABLE(VIDEO) >- if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) >- platformMediaSessionManager->stopAllMediaPlaybackForDocument(this); >+ stopAllMediaPlayback(); > #endif > > // We must call clearRareData() here since a Document class inherits TreeScope >@@ -1722,6 +1721,23 @@ void Document::allowsMediaDocumentInlinePlaybackChanged() > element->allowsMediaDocumentInlinePlaybackChanged(); > } > >+void Document::stopAllMediaPlayback() >+{ >+ if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) >+ platformMediaSessionManager->stopAllMediaPlaybackForDocument(this); >+} >+ >+void Document::suspendAllMediaPlayback() >+{ >+ if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) >+ platformMediaSessionManager->suspendAllMediaPlaybackForDocument(*this); >+} >+ >+void Document::resumeAllMediaPlayback() >+{ >+ if (auto* platformMediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) >+ platformMediaSessionManager->resumeAllMediaPlaybackForDocument(*this); >+} > #endif > > String Document::nodeName() const >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 5b5ff49b7f136c672245fe5bb924fafd8ae34e0b..9d7d8fa0b37bc17f37292deb660e953907ce0b78 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -1119,6 +1119,10 @@ public: > void registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&); > void unregisterForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&); > void allowsMediaDocumentInlinePlaybackChanged(); >+ >+ void stopAllMediaPlayback(); >+ void suspendAllMediaPlayback(); >+ void resumeAllMediaPlayback(); > #endif > > WEBCORE_EXPORT void setShouldCreateRenderers(bool); >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 0dcc88905063d2eb2709e62e34e95ea073b288a4..16ce879c5ab8af4474debb5548f1ae9c08c9452e 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -466,7 +466,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum > , m_haveSetUpCaptionContainer(false) > #endif > , m_isScrubbingRemotely(false) >- , m_shouldUnpauseInternalOnResume(false) > #if ENABLE(VIDEO_TRACK) > , m_tracksAreReady(true) > , m_haveVisibleTextTrack(false) >@@ -832,6 +831,7 @@ void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr > > // If a src attribute of a media element is set or changed, the user > // agent must invoke the media element's media element load algorithm. >+ INFO_LOG(LOGIDENTIFIER, "src = ", value); > if (!value.isNull()) > prepareForLoad(); > } else if (name == controlsAttr) >@@ -919,6 +919,8 @@ void HTMLMediaElement::didFinishInsertingNode() > { > Ref<HTMLMediaElement> protectedThis(*this); // prepareForLoad may result in a 'beforeload' event, which can make arbitrary DOM mutations. > >+ INFO_LOG(LOGIDENTIFIER); >+ > if (m_inActiveDocument && m_networkState == NETWORK_EMPTY && !attributeWithoutSynchronization(srcAttr).isEmpty()) > prepareForLoad(); > >@@ -1130,6 +1132,7 @@ void HTMLMediaElement::setSrcObject(MediaProvider&& mediaProvider) > // 4.7.14.2. Location of the media resource > // srcObject: On setting, it must set the elementâs assigned media provider object to the new > // value, and then invoke the elementâs media element load algorithm. >+ INFO_LOG(LOGIDENTIFIER); > m_mediaProvider = WTFMove(mediaProvider); > prepareForLoad(); > } >@@ -1762,10 +1765,16 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime) > if (nextCue) > nextInterestingTime = std::min(nextInterestingTime, nextCue->low()); > >+ INFO_LOG(LOGIDENTIFIER, "nextInterestingTime:", nextInterestingTime); >+ > if (nextInterestingTime.isValid() && m_player) { >- m_player->performTaskAtMediaTime([weakThis = makeWeakPtr(this), nextInterestingTime] { >- if (weakThis) >- weakThis->updateActiveTextTrackCues(weakThis->currentMediaTime()); >+ m_player->performTaskAtMediaTime([this, weakThis = makeWeakPtr(this), nextInterestingTime] { >+ if (!weakThis) >+ return; >+ >+ auto currentMediaTime = weakThis->currentMediaTime(); >+ INFO_LOG(LOGIDENTIFIER, " - lambda, currentMediaTime:", currentMediaTime); >+ weakThis->updateActiveTextTrackCues(currentMediaTime); > }, nextInterestingTime); > } > >@@ -5728,11 +5737,6 @@ void HTMLMediaElement::suspend(ReasonForSuspension reason) > m_mediaSession->addBehaviorRestriction(MediaElementSession::RequirePageConsentToResumeMedia); > break; > case ReasonForSuspension::PageWillBeSuspended: >- if (!m_pausedInternal) { >- m_shouldUnpauseInternalOnResume = true; >- setPausedInternal(true); >- } >- break; > case ReasonForSuspension::JavaScriptDebuggerPaused: > case ReasonForSuspension::WillDeferLoading: > // Do nothing, we don't pause media playback in these cases. >@@ -5748,11 +5752,6 @@ void HTMLMediaElement::resume() > > m_asyncEventQueue.resume(); > >- if (m_shouldUnpauseInternalOnResume) { >- m_shouldUnpauseInternalOnResume = false; >- setPausedInternal(false); >- } >- > setShouldBufferData(true); > > if (!m_mediaSession->pageAllowsPlaybackAfterResuming()) >@@ -5936,6 +5935,12 @@ void HTMLMediaElement::setShouldPlayToPlaybackTarget(bool shouldPlay) > > #endif // ENABLE(WIRELESS_PLAYBACK_TARGET) > >+bool HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless() const >+{ >+ INFO_LOG(LOGIDENTIFIER, m_isPlayingToWirelessTarget); >+ return m_isPlayingToWirelessTarget; >+} >+ > void HTMLMediaElement::setPlayingOnSecondScreen(bool value) > { > if (value == m_playingOnSecondScreen) >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index 360af8674cf8806212bc8259a98f57083988a2d2..910498d7567fa42ee8933f1de50cec8a49b3f88f 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -412,7 +412,7 @@ public: > void setShouldPlayToPlaybackTarget(bool) override; > #endif > bool isPlayingToWirelessPlaybackTarget() const override { return m_isPlayingToWirelessTarget; }; >- bool webkitCurrentPlaybackTargetIsWireless() const { return m_isPlayingToWirelessTarget; } >+ bool webkitCurrentPlaybackTargetIsWireless() const; > > void setPlayingOnSecondScreen(bool value); > bool isPlayingOnSecondScreen() const override { return m_playingOnSecondScreen; } >@@ -1110,7 +1110,6 @@ private: > > bool m_isScrubbingRemotely : 1; > bool m_waitingToEnterFullscreen : 1; >- bool m_shouldUnpauseInternalOnResume : 1; > > #if ENABLE(VIDEO_TRACK) > bool m_tracksAreReady : 1; >diff --git a/Source/WebCore/html/MediaElementSession.cpp b/Source/WebCore/html/MediaElementSession.cpp >index 0aba2d2e587f3bc35b626fba7c9f39454da1143a..22e2a16f2060e3d5efc70ec8c059be6bfab15522 100644 >--- a/Source/WebCore/html/MediaElementSession.cpp >+++ b/Source/WebCore/html/MediaElementSession.cpp >@@ -262,6 +262,10 @@ SuccessOr<MediaPlaybackDenialReason> MediaElementSession::playbackPermitted() co > } > > auto& document = m_element.document(); >+ auto* page = document.page(); >+ if (!page || page->mediaPlaybackIsSuspended()) >+ return MediaPlaybackDenialReason::PageConsentRequired; >+ > if (document.isMediaDocument() && !document.ownerElement()) > return { }; > >diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp >index fb0fc389a044f9b17513102b09c691da2bcf739c..592320737e62035ca1a9b41bec2e0f6b2cc88d34 100644 >--- a/Source/WebCore/page/Page.cpp >+++ b/Source/WebCore/page/Page.cpp >@@ -1716,6 +1716,41 @@ void Page::stopMediaCapture() > #endif > } > >+void Page::stopAllMediaPlayback() >+{ >+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { >+ if (auto* document = frame->document()) >+ document->stopAllMediaPlayback(); >+ } >+} >+ >+void Page::suspendAllMediaPlayback() >+{ >+ ASSERT(!m_mediaPlaybackIsSuspended); >+ if (m_mediaPlaybackIsSuspended) >+ return; >+ >+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { >+ if (auto* document = frame->document()) >+ document->suspendAllMediaPlayback(); >+ } >+ >+ m_mediaPlaybackIsSuspended = true; >+} >+ >+void Page::resumeAllMediaPlayback() >+{ >+ ASSERT(m_mediaPlaybackIsSuspended); >+ if (!m_mediaPlaybackIsSuspended) >+ return; >+ m_mediaPlaybackIsSuspended = false; >+ >+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { >+ if (auto* document = frame->document()) >+ document->resumeAllMediaPlayback(); >+ } >+} >+ > #if ENABLE(MEDIA_SESSION) > void Page::handleMediaEvent(MediaEventType eventType) > { >diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h >index d656f1e83effa14c58d572a18bbafbf7197d0e45..80215cefc814c0197c601a20752341f6971153f0 100644 >--- a/Source/WebCore/page/Page.h >+++ b/Source/WebCore/page/Page.h >@@ -600,6 +600,11 @@ public: > WEBCORE_EXPORT void setMuted(MediaProducer::MutedStateFlags); > WEBCORE_EXPORT void stopMediaCapture(); > >+ WEBCORE_EXPORT void stopAllMediaPlayback(); >+ WEBCORE_EXPORT void suspendAllMediaPlayback(); >+ WEBCORE_EXPORT void resumeAllMediaPlayback(); >+ bool mediaPlaybackIsSuspended() { return m_mediaPlaybackIsSuspended; } >+ > #if ENABLE(MEDIA_SESSION) > WEBCORE_EXPORT void handleMediaEvent(MediaEventType); > WEBCORE_EXPORT void setVolumeOfMediaElement(double, uint64_t); >@@ -945,6 +950,7 @@ private: > #endif > > bool m_shouldEnableICECandidateFilteringByDefault { true }; >+ bool m_mediaPlaybackIsSuspended { false }; > }; > > inline PageGroup& Page::group() >diff --git a/Source/WebCore/platform/audio/PlatformMediaSession.h b/Source/WebCore/platform/audio/PlatformMediaSession.h >index 17a30d5ceace5f8a09ee856ab5c13a516ef594a1..25c177990cf2613f25fe0ad00d8812429b6da0f2 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSession.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSession.h >@@ -85,6 +85,7 @@ public: > SuspendedUnderLock, > InvisibleAutoplay, > ProcessInactive, >+ PlaybackSuspended, > }; > InterruptionType interruptionType() const { return m_interruptionType; } > >diff --git a/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp b/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >index 1a305d173bb02314fbd8505798f21e0f8d41d48a..d29d7b2b7d53bbbb00a16a6463e15b6a3a054bed 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >+++ b/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp >@@ -419,6 +419,22 @@ void PlatformMediaSessionManager::stopAllMediaPlaybackForProcess() > }); > } > >+void PlatformMediaSessionManager::suspendAllMediaPlaybackForDocument(const Document& document) >+{ >+ forEachSession([&] (PlatformMediaSession& session, size_t) { >+ if (session.client().hostingDocument() == &document) >+ session.beginInterruption(PlatformMediaSession::PlaybackSuspended); >+ }); >+} >+ >+void PlatformMediaSessionManager::resumeAllMediaPlaybackForDocument(const Document& document) >+{ >+ forEachSession([&] (PlatformMediaSession& session, size_t) { >+ if (session.client().hostingDocument() == &document) >+ session.endInterruption(PlatformMediaSession::MayResumePlaying); >+ }); >+} >+ > void PlatformMediaSessionManager::forEachSession(const Function<void(PlatformMediaSession&, size_t)>& predicate) const > { > ++m_iteratingOverSessions; >diff --git a/Source/WebCore/platform/audio/PlatformMediaSessionManager.h b/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >index 4d87fd8f8ae01a35ee8161cf0de54b6ebd78aa9b..e670dafc113131daa4e282c9c40bb209327b4832 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSessionManager.h >@@ -77,6 +77,9 @@ public: > void stopAllMediaPlaybackForDocument(const Document*); > WEBCORE_EXPORT void stopAllMediaPlaybackForProcess(); > >+ void suspendAllMediaPlaybackForDocument(const Document&); >+ void resumeAllMediaPlaybackForDocument(const Document&); >+ > enum SessionRestrictionFlags { > NoRestrictions = 0, > ConcurrentPlaybackNotPermitted = 1 << 0, >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 7405871f1446ec24e8fc3497058d88f99e84e22f..a683b5c15e8ff14b75cc016d22d3355edc8dc3d1 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -4484,6 +4484,21 @@ - (void)_togglePictureInPicture > #endif > } > >+- (void)_stopAllMediaPlayback >+{ >+ _page->stopAllMediaPlayback(); >+} >+ >+- (void)_suspendAllMediaPlayback >+{ >+ _page->suspendAllMediaPlayback(); >+} >+ >+- (void)_resumeAllMediaPlayback >+{ >+ _page->resumeAllMediaPlayback(); >+} >+ > - (NSURL *)_unreachableURL > { > return [NSURL _web_URLWithWTFString:_page->pageLoadState().unreachableURL()]; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >index 170c2aaefa150b41f996cce468ce32779bad6f8f..7a16e5dd57b6f49b58492f31b0b913a89e921d8b 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >@@ -399,7 +399,9 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) { > @property (nonatomic, readonly) BOOL _isPictureInPictureActive; > - (void)_updateMediaPlaybackControlsManager; > - (void)_togglePictureInPicture; >- >+- (void)_stopAllMediaPlayback; >+- (void)_suspendAllMediaPlayback; >+- (void)_resumeAllMediaPlayback; > @end > > #if TARGET_OS_IPHONE >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index ac80a7b59db43d99966df69315a9c83d2010ff66..33990a264c8dcd83f5674eb242ff3052095c4f48 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -4963,6 +4963,30 @@ void WebPageProxy::stopMediaCapture() > #endif > } > >+void WebPageProxy::stopAllMediaPlayback() >+{ >+ if (!isValid()) >+ return; >+ >+ m_process->send(Messages::WebPage::StopAllMediaPlayback(), m_pageID); >+} >+ >+void WebPageProxy::suspendAllMediaPlayback() >+{ >+ if (!isValid()) >+ return; >+ >+ m_process->send(Messages::WebPage::SuspendAllMediaPlayback(), m_pageID); >+} >+ >+void WebPageProxy::resumeAllMediaPlayback() >+{ >+ if (!isValid()) >+ return; >+ >+ m_process->send(Messages::WebPage::ResumeAllMediaPlayback(), m_pageID); >+} >+ > #if ENABLE(MEDIA_SESSION) > void WebPageProxy::handleMediaEvent(MediaEventType eventType) > { >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 734d211719e94bff95a961f3f0d6309ccc3efa15..b7719c168909d5d21cb3abfe239fd084675d112c 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1117,6 +1117,10 @@ public: > bool mediaCaptureEnabled() const { return m_mediaCaptureEnabled; } > void stopMediaCapture(); > >+ void stopAllMediaPlayback(); >+ void suspendAllMediaPlayback(); >+ void resumeAllMediaPlayback(); >+ > #if ENABLE(MEDIA_SESSION) > bool hasMediaSessionWithActiveMediaElements() const { return m_hasMediaSessionWithActiveMediaElements; } > void handleMediaEvent(WebCore::MediaEventType); >diff --git a/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm b/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm >index 50c1f51ce068e5c020424d733a18ab01cc41e29b..f6924ccba36e079024e720bf79b243f81cc49f90 100644 >--- a/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm >+++ b/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm >@@ -559,13 +559,17 @@ - (void)_showPhishingAlert > NSString *alertMessage = [NSString stringWithFormat:WEB_UI_STRING("Typing is not allowed in full screen websites. â%@â may be showing a fake keyboard to trick you into disclosing personal or financial information.", "Full Screen Deceptive Website Warning Sheet Content Text"), (NSString *)self.location]; > UIAlertController* alert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; > >- if (auto* page = [self._webView _page]) >+ if (auto* page = [self._webView _page]) { >+ page->suspendAllMediaPlayback(); > page->suspendActiveDOMObjectsAndAnimations(); >+ } > > UIAlertAction* exitAction = [UIAlertAction actionWithTitle:WEB_UI_STRING_KEY("Exit Full Screen", "Exit Full Screen (Element Full Screen)", "Full Screen Deceptive Website Exit Action") style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { > [self _cancelAction:action]; >- if (auto* page = [self._webView _page]) >+ if (auto* page = [self._webView _page]) { > page->resumeActiveDOMObjectsAndAnimations(); >+ page->resumeAllMediaPlayback(); >+ } > }]; > > UIAlertAction* stayAction = [UIAlertAction actionWithTitle:WEB_UI_STRING_KEY("Stay in Full Screen", "Stay in Full Screen (Element Full Screen)", "Full Screen Deceptive Website Stay Action") style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index c355d54ade902eb3653fce439d0f86c1d87ec599..d935b2d48a715283c1b1494f6889887c249b9295 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,20 @@ >+2018-12-18 Jer Noble <jer.noble@apple.com> >+ >+ [Fullscreen] Suspend page (and pause video) while phishing warining is presented >+ https://bugs.webkit.org/show_bug.cgi?id=186856 >+ <rdar://problem/41212444> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm: Added. >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm: Added. >+ (-[ScrollingDoesNotPauseMediaDelegate webViewDidFinishLoad:]): >+ (-[ScrollingDoesNotPauseMediaDelegate uiWebView:didCommitLoadForFrame:]): >+ (-[ScrollingDoesNotPauseMediaDelegate handleEvent:]): >+ (TestWebKitAPI::TEST): >+ > 2018-10-31 Jer Noble <jer.noble@apple.com> > > SDK_VARIANT build destinations should be separate from non-SDK_VARIANT builds >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 6d7fa37d9ccef498e32838c0cd63715862b0449d..14985539aa31e72cd0f8bffba329e343809362cd 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -761,6 +761,8 @@ > CDB5DFFF213610FA00D3E189 /* now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB5DFFE21360ED800D3E189 /* now-playing.html */; }; > CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; }; > CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */; }; >+ CDC0932B21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC0932A21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm */; }; >+ CDC0932E21C993440030C4B0 /* StopSuspendResumeAllMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC0932D21C993440030C4B0 /* StopSuspendResumeAllMedia.mm */; }; > CDC8E48D1BC5CB4500594FEC /* AudioSessionCategoryIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC8E4851BC5B19400594FEC /* AudioSessionCategoryIOS.mm */; }; > CDC8E4941BC6F10800594FEC /* video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDC8E4891BC5C96200594FEC /* video-with-audio.html */; }; > CDC8E4951BC6F10800594FEC /* video-with-audio.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDC8E48A1BC5C96200594FEC /* video-with-audio.mp4 */; }; >@@ -2040,6 +2042,8 @@ > CDB5DFFE21360ED800D3E189 /* now-playing.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "now-playing.html"; sourceTree = "<group>"; }; > CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenZoomInitialFrame.html; sourceTree = "<group>"; }; > CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenZoomInitialFrame.mm; sourceTree = "<group>"; }; >+ CDC0932A21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingDoesNotPauseMedia.mm; sourceTree = "<group>"; }; >+ CDC0932D21C993440030C4B0 /* StopSuspendResumeAllMedia.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = StopSuspendResumeAllMedia.mm; sourceTree = "<group>"; }; > CDC2C7141797089D00E627FB /* TimeRanges.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TimeRanges.cpp; sourceTree = "<group>"; }; > CDC8E4851BC5B19400594FEC /* AudioSessionCategoryIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioSessionCategoryIOS.mm; sourceTree = "<group>"; }; > CDC8E4891BC5C96200594FEC /* video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-audio.html"; sourceTree = "<group>"; }; >@@ -2563,6 +2567,7 @@ > 37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */, > 93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */, > 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */, >+ CDC0932D21C993440030C4B0 /* StopSuspendResumeAllMedia.mm */, > ); > name = "WebKit Cocoa"; > path = WebKitCocoa; >@@ -3515,6 +3520,7 @@ > CDC8E49A1BC728FE00594FEC /* Resources */, > CDC8E4851BC5B19400594FEC /* AudioSessionCategoryIOS.mm */, > 0F4FFA9D1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm */, >+ CDC0932A21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm */, > ); > path = ios; > sourceTree = "<group>"; >@@ -3846,6 +3852,7 @@ > 57303BCA20082C0100355965 /* CBORWriterTest.cpp in Sources */, > F4517B7F2055101B00C26721 /* ClassMethodSwizzler.mm in Sources */, > 7CCE7EE61A411AE600447C4C /* CloseFromWithinCreatePage.cpp in Sources */, >+ CDC0932B21C872C10030C4B0 /* ScrollingDoesNotPauseMedia.mm in Sources */, > 7CCE7EB71A411A7E00447C4C /* CloseNewWindowInNavigationPolicyDelegate.mm in Sources */, > 7CCE7EE51A411AE600447C4C /* CloseThenTerminate.cpp in Sources */, > CDF92237216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm in Sources */, >@@ -4134,6 +4141,7 @@ > 7CCE7ECF1A411A7E00447C4C /* StopLoadingFromDidReceiveResponse.mm in Sources */, > 515BE1711D428E4B00DD7C68 /* StoreBlobThenDelete.mm in Sources */, > 7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */, >+ CDC0932E21C993440030C4B0 /* StopSuspendResumeAllMedia.mm in Sources */, > 7CCE7ED11A411A7E00447C4C /* StringTruncator.mm in Sources */, > ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */, > CE4D5DE71F6743BA0072CFC6 /* StringWithDirection.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..0d99ab69882cbab57ae5efb5c01f843ac214712a >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm >@@ -0,0 +1,88 @@ >+/* >+ * Copyright (C) 2018 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" >+ >+#if WK_API_ENABLED && PLATFORM(MAC) >+ >+#import "PlatformUtilities.h" >+#import "TestWKWebView.h" >+#import <WebKit/WKWebViewPrivate.h> >+#import <wtf/RetainPtr.h> >+ >+namespace TestWebKitAPI { >+ >+TEST(WKWebView, StopAllMediaPlayback) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]); >+ >+ [webView synchronouslyLoadHTMLString:@"<video src=\"video-with-audio.mp4\" webkit-playsinline></video>"]; >+ >+ [webView objectByEvaluatingJavaScript:@"function eventToMessage(event){window.webkit.messageHandlers.testHandler.postMessage(event.type);} var video = document.querySelector('video'); video.addEventListener('playing', eventToMessage); video.addEventListener('pause', eventToMessage);"]; >+ >+ __block bool didBeginPlaying = false; >+ [webView performAfterReceivingMessage:@"playing" action:^{ didBeginPlaying = true; }]; >+ [webView evaluateJavaScript:@"document.querySelector('video').play()" completionHandler:nil]; >+ TestWebKitAPI::Util::run(&didBeginPlaying); >+ >+ __block bool didPause = false; >+ [webView performAfterReceivingMessage:@"pause" action:^{ didPause = true; }]; >+ [webView _stopAllMediaPlayback]; >+ TestWebKitAPI::Util::run(&didPause); >+} >+ >+TEST(WKWebView, SuspendResumeAllMediaPlayback) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]); >+ >+ [webView synchronouslyLoadHTMLString:@"<video src=\"video-with-audio.mp4\" webkit-playsinline></video>"]; >+ >+ [webView objectByEvaluatingJavaScript:@"function eventToMessage(event){window.webkit.messageHandlers.testHandler.postMessage(event.type);} var video = document.querySelector('video'); video.addEventListener('playing', eventToMessage); video.addEventListener('pause', eventToMessage);"]; >+ >+ __block bool didBeginPlaying = false; >+ [webView performAfterReceivingMessage:@"playing" action:^{ didBeginPlaying = true; }]; >+ [webView evaluateJavaScript:@"document.querySelector('video').play()" completionHandler:nil]; >+ TestWebKitAPI::Util::run(&didBeginPlaying); >+ >+ __block bool didPause = false; >+ [webView performAfterReceivingMessage:@"pause" action:^{ didPause = true; }]; >+ [webView _suspendAllMediaPlayback]; >+ TestWebKitAPI::Util::run(&didPause); >+ >+ __block bool didReject = false; >+ [webView performAfterReceivingMessage:@"rejected" action:^{ didReject = true; }]; >+ [webView evaluateJavaScript:@"document.querySelector('video').play().catch(() = { window.webkit.messageHandlers.testHandler.postMessage('rejected'); })" completionHandler:nil]; >+ >+ didBeginPlaying = false; >+ [webView performAfterReceivingMessage:@"playing" action:^{ didBeginPlaying = true; }]; >+ [webView _resumeAllMediaPlayback]; >+ TestWebKitAPI::Util::run(&didBeginPlaying); >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm b/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..dc0e09044ce10845e8dc477fa4aa4b99c53c2c9c >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm >@@ -0,0 +1,114 @@ >+/* >+ * Copyright (C) 2018 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" >+ >+#if PLATFORM(IOS_FAMILY) >+ >+#import "PlatformUtilities.h" >+#import <WebKit/DOMHTMLMediaElement.h> >+#import <WebKit/WebFramePrivate.h> >+#import <wtf/RetainPtr.h> >+ >+@interface ScrollingDoesNotPauseMediaDelegate : NSObject <UIWebViewDelegate, DOMEventListener> { >+} >+@end >+ >+static bool didFinishLoad; >+static bool gotMainFrame; >+static WebFrame* mainFrame; >+ >+@implementation ScrollingDoesNotPauseMediaDelegate >+ >+IGNORE_WARNINGS_BEGIN("deprecated-implementations") >+- (void)webViewDidFinishLoad:(UIWebView *)webView >+IGNORE_WARNINGS_END >+{ >+ didFinishLoad = true; >+} >+ >+- (void)uiWebView:(UIWebView *)sender didCommitLoadForFrame:(WebFrame *)frame >+{ >+ mainFrame = frame; >+ gotMainFrame = true; >+} >+ >+static bool didReceivePause; >+static bool didReceivePlaying; >+ >+- (void)handleEvent:(DOMEvent *)event >+{ >+ if ([event.type isEqualToString:@"pause"]) >+ didReceivePause = true; >+ else if ([event.type isEqualToString:@"playing"]) >+ didReceivePlaying = true; >+} >+@end >+ >+namespace TestWebKitAPI { >+ >+TEST(WebKitLegacy, ScrollingDoesNotPauseMedia) >+{ >+ RetainPtr<UIWindow> uiWindow = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); >+ RetainPtr<UIWebView> uiWebView = adoptNS([[UIWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); >+ [uiWindow addSubview:uiWebView.get()]; >+ >+ uiWebView.get().mediaPlaybackRequiresUserAction = NO; >+ uiWebView.get().allowsInlineMediaPlayback = YES; >+ >+ RetainPtr<ScrollingDoesNotPauseMediaDelegate> testController = adoptNS([ScrollingDoesNotPauseMediaDelegate new]); >+ uiWebView.get().delegate = testController.get(); >+ >+ didFinishLoad = false; >+ gotMainFrame = false; >+ mainFrame = nil; >+ >+ [uiWebView loadRequest:[NSURLRequest requestWithURL:[NSBundle.mainBundle URLForResource:@"video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; >+ >+ Util::run(&didFinishLoad); >+ Util::run(&gotMainFrame); >+ >+ DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[mainFrame.DOMDocument querySelector:@"video"]; >+ ASSERT_TRUE([video isKindOfClass:[DOMHTMLMediaElement class]]); >+ >+ [video addEventListener:@"playing" listener:testController.get() useCapture:NO]; >+ [video addEventListener:@"pause" listener:testController.get() useCapture:NO]; >+ >+ [mainFrame setTimeoutsPaused:YES]; >+ >+ didReceivePlaying = false; >+ [video play]; >+ Util::run(&didReceivePlaying); >+ >+ [mainFrame setTimeoutsPaused:NO]; >+ >+ didReceivePause = false; >+ [video play]; >+ Util::run(&didReceivePause); >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186856
:
343164
|
343249
|
343250
|
357608