Diff
Modified: trunk/LayoutTests/ChangeLog (252336 => 252337)
--- trunk/LayoutTests/ChangeLog 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/LayoutTests/ChangeLog 2019-11-11 21:41:09 UTC (rev 252337)
@@ -1,3 +1,14 @@
+2019-11-11 Youenn Fablet <[email protected]>
+
+ Make MediaStream/MediaStreamTrack page cache friendly
+ https://bugs.webkit.org/show_bug.cgi?id=204030
+
+ Reviewed by Chris Dumez.
+
+ * platform/mac-wk1/TestExpectations: Disabled test for WK1.
+ * http/tests/navigation/page-cache-mediastream-expected.txt: Added.
+ * http/tests/navigation/page-cache-mediastream.html: Added.
+
2019-11-11 Matt Lewis <[email protected]>
Unreviewed, rolling out r252076.
Added: trunk/LayoutTests/http/tests/navigation/page-cache-mediastream-expected.txt (0 => 252337)
--- trunk/LayoutTests/http/tests/navigation/page-cache-mediastream-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-mediastream-expected.txt 2019-11-11 21:41:09 UTC (rev 252337)
@@ -0,0 +1,13 @@
+Tests that a page with a capture track goes into the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+pageshow - not from cache
+pagehide - entering cache
+pageshow - from cache
+PASS Page did enter and was restored from the page cache
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/navigation/page-cache-mediastream.html (0 => 252337)
--- trunk/LayoutTests/http/tests/navigation/page-cache-mediastream.html (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-mediastream.html 2019-11-11 21:41:09 UTC (rev 252337)
@@ -0,0 +1,54 @@
+<!-- webkit-test-runner [ enableBackForwardCache=true ] -->
+<!DOCTYPE html>
+<html>
+<body>
+<canvas id="myCanvas"></canvas>
+<script src=""
+<script>
+description('Tests that a page with a capture track goes into the page cache.');
+window.jsTestIsAsync = true;
+
+var restoredFromPageCache = false;
+
+window.addEventListener("pageshow", function(event) {
+ debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+ if (event.persisted) {
+ testPassed("Page did enter and was restored from the page cache");
+ restoredFromPageCache = true;
+
+ if (!canvasStream.active)
+ testFailed("Canvas stream is not active");
+
+ if (gumStream.active)
+ testFailed("GUM stream is active");
+ }
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+ debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+ if (!event.persisted) {
+ testFailed("Page did not enter the page cache.");
+ finishJSTest();
+ }
+}, false);
+
+var gumStream;
+var canvasStream;
+
+window.addEventListener('load', async function() {
+ gumStream = await navigator.mediaDevices.getUserMedia({ audio: true });
+ gumStream.getAudioTracks()[0]._onended_ = finishJSTest;
+ canvasStream = myCanvas.captureStream();
+ // This needs to happen in a setTimeout because a navigation inside the onload handler would
+ // not create a history entry.
+ setTimeout(function() {
+ // Force a back navigation back to this page.
+ window.location.href = ""
+ }, 0);
+}, false);
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (252336 => 252337)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2019-11-11 21:41:09 UTC (rev 252337)
@@ -60,6 +60,7 @@
http/tests/ssl/media-stream
inspector/page/overrideSetting-MockCaptureDevicesEnabled.html [ Skip ]
http/tests/navigation/page-cache-getUserMedia-pending-promise.html [ Skip ]
+http/tests/navigation/page-cache-mediastream.html [ Skip ]
# Datalist is unsupported in WK1
accessibility/datalist.html [ WontFix ]
Modified: trunk/Source/WebCore/ChangeLog (252336 => 252337)
--- trunk/Source/WebCore/ChangeLog 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/Source/WebCore/ChangeLog 2019-11-11 21:41:09 UTC (rev 252337)
@@ -1,3 +1,20 @@
+2019-11-11 Youenn Fablet <[email protected]>
+
+ Make MediaStream/MediaStreamTrack page cache friendly
+ https://bugs.webkit.org/show_bug.cgi?id=204030
+
+ Reviewed by Chris Dumez.
+
+ Test: http/tests/navigation/page-cache-mediastream.html
+
+ * Modules/mediastream/MediaStream.cpp:
+ Remove the unnneeded opt-out of page cache in case of MediaStream.
+ * Modules/mediastream/MediaStream.h:
+ * Modules/mediastream/MediaStreamTrack.cpp:
+ (WebCore::MediaStreamTrack::suspend):
+ In case of a capture track, end it at suspend time but fire ended event at resume time.
+ * Modules/mediastream/MediaStreamTrack.h:
+
2019-11-11 Matt Lewis <[email protected]>
Unreviewed, rolling out r252076.
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (252336 => 252337)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2019-11-11 21:41:09 UTC (rev 252337)
@@ -400,12 +400,6 @@
return "MediaStream";
}
-// FIXME: This should never prevent entering the back/forward cache.
-bool MediaStream::shouldPreventEnteringBackForwardCache_DEPRECATED() const
-{
- return hasPendingActivity();
-}
-
bool MediaStream::hasPendingActivity() const
{
return m_isActive;
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.h (252336 => 252337)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.h 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.h 2019-11-11 21:41:09 UTC (rev 252337)
@@ -146,7 +146,6 @@
// ActiveDOMObject API.
void stop() final;
const char* activeDOMObjectName() const final;
- bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;
void updateActiveState();
void activityEventTimerFired();
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (252336 => 252337)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2019-11-11 21:41:09 UTC (rev 252337)
@@ -556,10 +556,18 @@
return "MediaStreamTrack";
}
-// FIXME: This should never prevent entering the back/forward cache.
-bool MediaStreamTrack::shouldPreventEnteringBackForwardCache_DEPRECATED() const
+void MediaStreamTrack::suspend(ReasonForSuspension reason)
{
- return hasPendingActivity();
+ if (reason != ReasonForSuspension::BackForwardCache)
+ return;
+
+ // We only end capture tracks, other tracks (capture canvas, remote tracks) can still continue working.
+ if (m_ended || !isCaptureTrack())
+ return;
+
+ stopTrack();
+
+ queueTaskToDispatchEvent(*this, TaskSource::Networking, Event::create(eventNames().endedEvent, Event::CanBubble::No, Event::IsCancelable::No));
}
bool MediaStreamTrack::hasPendingActivity() const
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (252336 => 252337)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-11-11 19:42:17 UTC (rev 252336)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-11-11 21:41:09 UTC (rev 252337)
@@ -177,7 +177,7 @@
// ActiveDOMObject API.
void stop() final;
const char* activeDOMObjectName() const final;
- bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;
+ void suspend(ReasonForSuspension) final;
// EventTarget
void refEventTarget() final { ref(); }