<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[180791] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/180791">180791</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-02-27 15:46:01 -0800 (Fri, 27 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make SourceBuffer ActiveDOMObject suspendable
https://bugs.webkit.org/show_bug.cgi?id=142108
&lt;rdar://problem/19923085&gt;

Reviewed by Jer Noble.

Source/WebCore:

Make SourceBuffer ActiveDOMObject suspendable if it is removed from its
MediaSource and does not have any pending events. This makes it more
likely for pages using SourceBuffer objects to go into the PageCache.

Test: fast/history/page-cache-removed-source-buffer.html

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::canSuspend):
* Modules/mediasource/SourceBuffer.h:

LayoutTests:

Add a layout tests to check that a SourceBuffer removed from its
MediaSource does not prevent a Page from entering PageCache.

* fast/history/page-cache-removed-source-buffer-expected.txt: Added.
* fast/history/page-cache-removed-source-buffer.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformeflTestExpectations">trunk/LayoutTests/platform/efl/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwincairoTestExpectations">trunk/LayoutTests/platform/wincairo/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSourceBuffercpp">trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSourceBufferh">trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasthistorypagecacheremovedsourcebufferexpectedtxt">trunk/LayoutTests/fast/history/page-cache-removed-source-buffer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthistorypagecacheremovedsourcebufferhtml">trunk/LayoutTests/fast/history/page-cache-removed-source-buffer.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/LayoutTests/ChangeLog        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-02-27  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Make SourceBuffer ActiveDOMObject suspendable
+        https://bugs.webkit.org/show_bug.cgi?id=142108
+        &lt;rdar://problem/19923085&gt;
+
+        Reviewed by Jer Noble.
+
+        Add a layout tests to check that a SourceBuffer removed from its
+        MediaSource does not prevent a Page from entering PageCache.
+
+        * fast/history/page-cache-removed-source-buffer-expected.txt: Added.
+        * fast/history/page-cache-removed-source-buffer.html: Added.
+
</ins><span class="cx"> 2015-02-26  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for canvas ellipse method
</span></span></pre></div>
<a id="trunkLayoutTestsfasthistorypagecacheremovedsourcebufferexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/history/page-cache-removed-source-buffer-expected.txt (0 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/history/page-cache-removed-source-buffer-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-removed-source-buffer-expected.txt        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Tests that a SourceBuffer removed from its MediaSource does not prevent a Page from entering PageCache
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthistorypagecacheremovedsourcebufferhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/history/page-cache-removed-source-buffer.html (0 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/history/page-cache-removed-source-buffer.html                                (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-removed-source-buffer.html        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description('Tests that a SourceBuffer removed from its MediaSource does not prevent a Page from entering PageCache');
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.overridePreference(&quot;WebKitUsesPageCachePreferenceKey&quot;, 1);
+
+window.addEventListener(&quot;pageshow&quot;, function(event) {
+    debug(&quot;pageshow - &quot; + (event.persisted ? &quot;&quot; : &quot;not &quot;) + &quot;from cache&quot;);
+
+    if (event.persisted) {
+        testPassed(&quot;Page did enter and was restored from the page cache&quot;);
+        finishJSTest();
+    }
+}, false);
+
+window.addEventListener(&quot;pagehide&quot;, function(event) {
+    debug(&quot;pagehide - &quot; + (event.persisted ? &quot;&quot; : &quot;not &quot;) + &quot;entering cache&quot;);
+    if (!event.persisted) {
+        testFailed(&quot;Page did not enter the page cache.&quot;);
+        finishJSTest();
+    }
+}, false);
+
+window.addEventListener('load', function() {
+    // Construct a MediaSource and open it.
+    mediaSource = new MediaSource();
+    mediaTag = document.createElement(&quot;video&quot;);
+    document.body.appendChild(mediaTag);
+    mediaSourceURL = URL.createObjectURL(mediaSource);
+    mediaTag.src = mediaSourceURL;
+
+    window.sessionStorage.page_cache_open_mediasource_test_started = true;
+
+    mediaSource.addEventListener('sourceopen', function() {
+        sourceBuffer = mediaSource.addSourceBuffer('audio/mp4;codecs=&quot;mp4a.40.2&quot;');
+
+        // Cause the MediaSource to close so that it does not prevent page caching.
+        mediaTag.src = &quot;&quot;;
+    });
+
+    mediaSource.addEventListener('sourceclose', function() {
+        // Force a back navigation back to this page.
+        window.location.href = &quot;resources/page-cache-helper.html&quot;;
+    });
+}, false);
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformeflTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/TestExpectations (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/TestExpectations        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/LayoutTests/platform/efl/TestExpectations        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -1052,6 +1052,7 @@
</span><span class="cx"> webkit.org/b/95296 fast/history/page-cache-media-source-opened.html [ Skip ]
</span><span class="cx"> webkit.org/b/95296 fast/history/page-cache-media-source-closed.html [ Skip ]
</span><span class="cx"> webkit.org/b/95296 fast/history/page-cache-media-source-closed-2.html [ Skip ]
</span><ins>+webkit.org/b/95296 fast/history/page-cache-removed-source-buffer.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # Requires ENCRYPTED_MEDIA support.
</span><span class="cx"> webkit.org/b/95297 media/encrypted-media [ Pass ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -955,6 +955,7 @@
</span><span class="cx"> [ Mavericks ] fast/history/page-cache-media-source-closed.html [ WontFix ]
</span><span class="cx"> [ Mavericks ] fast/history/page-cache-media-source-closed-2.html [ WontFix ]
</span><span class="cx"> [ Mavericks ] fast/history/page-cache-media-source-opened.html [ WontFix ]
</span><ins>+[ Mavericks ] fast/history/page-cache-removed-source-buffer.html [ WontFix ]
</ins><span class="cx"> ## --- End media tests failing on Mavericks and earlier ---
</span><span class="cx"> 
</span><span class="cx"> ## --- Start flaky media tests ---
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/win/TestExpectations        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/LayoutTests/platform/win/TestExpectations        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -805,6 +805,7 @@
</span><span class="cx"> webkit.org/b/64731 fast/history/page-cache-media-source-opened.html [ Skip ]
</span><span class="cx"> webkit.org/b/64731 fast/history/page-cache-media-source-closed.html [ Skip ]
</span><span class="cx"> webkit.org/b/64731 fast/history/page-cache-media-source-closed-2.html  [ Skip ]
</span><ins>+webkit.org/b/64731 fast/history/page-cache-removed-source-buffer.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # These tests are for an obsolete version of the EME spec.
</span><span class="cx"> fast/events/constructors/media-key-event-constructor.html [ Skip ] # [ WontFix ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwincairoTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/wincairo/TestExpectations        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -2001,6 +2001,7 @@
</span><span class="cx"> fast/history/page-cache-media-source-opened.html
</span><span class="cx"> fast/history/page-cache-media-source-closed.html
</span><span class="cx"> fast/history/page-cache-media-source-closed-2.html
</span><ins>+fast/history/page-cache-removed-source-buffer.html
</ins><span class="cx"> 
</span><span class="cx"> # Encrypted Media Extensions are not enabled.
</span><span class="cx"> media/encrypted-media/
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/Source/WebCore/ChangeLog        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-02-27  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Make SourceBuffer ActiveDOMObject suspendable
+        https://bugs.webkit.org/show_bug.cgi?id=142108
+        &lt;rdar://problem/19923085&gt;
+
+        Reviewed by Jer Noble.
+
+        Make SourceBuffer ActiveDOMObject suspendable if it is removed from its
+        MediaSource and does not have any pending events. This makes it more
+        likely for pages using SourceBuffer objects to go into the PageCache.
+
+        Test: fast/history/page-cache-removed-source-buffer.html
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::canSuspend):
+        * Modules/mediasource/SourceBuffer.h:
+
</ins><span class="cx"> 2015-02-26  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for canvas ellipse method
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -510,6 +510,11 @@
</span><span class="cx">     m_removeTimer.stop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool SourceBuffer::canSuspend() const
+{
+    return !hasPendingActivity();
+}
+
</ins><span class="cx"> bool SourceBuffer::isRemoved() const
</span><span class="cx"> {
</span><span class="cx">     return !m_source;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (180790 => 180791)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2015-02-27 23:40:35 UTC (rev 180790)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2015-02-27 23:46:01 UTC (rev 180791)
</span><span class="lines">@@ -109,6 +109,7 @@
</span><span class="cx">     // ActiveDOMObject interface
</span><span class="cx">     virtual bool hasPendingActivity() const override;
</span><span class="cx">     virtual void stop() override;
</span><ins>+    bool canSuspend() const override;
</ins><span class="cx"> 
</span><span class="cx">     // EventTarget interface
</span><span class="cx">     virtual ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
</span></span></pre>
</div>
</div>

</body>
</html>