Title: [180646] trunk
Revision
180646
Author
cdu...@apple.com
Date
2015-02-25 15:49:08 -0800 (Wed, 25 Feb 2015)

Log Message

Make PublicURLManager suspendable
https://bugs.webkit.org/show_bug.cgi?id=141977
<rdar://problem/19923085>

Reviewed by Andreas Kling.

Source/WebCore:

Make PublicURLManager suspendable by overriding ActiveDOMObject::canSuspend()
and returning true. Nothing prevents suspending the PublicURLManager as its
implementation never causes JS to be executed. No implementation for
suspend() / resume() needs to be provided for the same reason.

The fact that PublicURLManager wasn't suspendable was preventing pages using
URL.createObjectURL() from entering the PageCache. Baidu.com search results
pages are using the API for example.

Test: fast/history/page-cache-createObjectURL.html

* html/PublicURLManager.cpp:
(WebCore::PublicURLManager::canSuspend):
* html/PublicURLManager.h:

LayoutTests:

Add a layout test to check that a page using URL.createObjectURL() API
can enter the PageCache.

* fast/history/page-cache-createObjectURL-expected.txt: Added.
* fast/history/page-cache-createObjectURL.html: Added.

* platform/wk2/TestExpectations:
  The new test is skipped on WK2 because WKTR does not support
  eventSender.beginDragWithFiles().

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (180645 => 180646)


--- trunk/LayoutTests/ChangeLog	2015-02-25 23:42:38 UTC (rev 180645)
+++ trunk/LayoutTests/ChangeLog	2015-02-25 23:49:08 UTC (rev 180646)
@@ -1,3 +1,21 @@
+2015-02-25  Chris Dumez  <cdu...@apple.com>
+
+        Make PublicURLManager suspendable
+        https://bugs.webkit.org/show_bug.cgi?id=141977
+        <rdar://problem/19923085>
+
+        Reviewed by Andreas Kling.
+
+        Add a layout test to check that a page using URL.createObjectURL() API
+        can enter the PageCache.
+
+        * fast/history/page-cache-createObjectURL-expected.txt: Added.
+        * fast/history/page-cache-createObjectURL.html: Added.
+
+        * platform/wk2/TestExpectations:
+          The new test is skipped on WK2 because WKTR does not support
+          eventSender.beginDragWithFiles().
+
 2015-02-25  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Horizontal and vertical lines are clipped completely if clip-path is included in the tag but the referenced element is defined later.

Added: trunk/LayoutTests/fast/history/page-cache-createObjectURL-expected.txt (0 => 180646)


--- trunk/LayoutTests/fast/history/page-cache-createObjectURL-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-createObjectURL-expected.txt	2015-02-25 23:49:08 UTC (rev 180646)
@@ -0,0 +1,24 @@
+Tests that a page calling URL.createObjectURL() can use the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS img.width is 0
+PASS img.height is 0
+img.src = ""
+pageshow - not from cache
+PASS Image loaded
+PASS img.width is 76
+PASS img.height is 103
+pagehide - entering cache
+pageshow - from cache
+PASS Page did enter and was restored from the page cache
+Reuse the previous blobURL
+img2.src = ""
+PASS Image2 loaded
+PASS img2.width is 76
+PASS img2.height is 103
+PASS successfullyParsed is true
+
+TEST COMPLETE
+  

Added: trunk/LayoutTests/fast/history/page-cache-createObjectURL.html (0 => 180646)


--- trunk/LayoutTests/fast/history/page-cache-createObjectURL.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-createObjectURL.html	2015-02-25 23:49:08 UTC (rev 180646)
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+
+<input type="file" name="file" id="file" _onchange_="onInputFileChange()"/>
+<img id='imgToReplace1' src=''/>
+<img id='imgToReplace2' src=''/>
+
+<script>
+description('Tests that a page calling URL.createObjectURL() can use the page cache.');
+window.jsTestIsAsync = true;
+var blobURL = null;
+
+if (window.testRunner)
+    window.testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+
+function onInputFileChange()
+{
+    var file = document.getElementById("file").files[0];
+    img = document.getElementById('imgToReplace1');
+    shouldBe("img.width", "0");
+    shouldBe("img.height", "0");
+    img._onload_ = onImgLoad;
+    blobURL = URL.createObjectURL(file);
+    evalAndLog("img.src = ""
+}
+
+function onImgLoad()
+{
+    img = document.getElementById('imgToReplace1');
+    testPassed("Image loaded");
+    shouldBe("img.width", "76");
+    shouldBe("img.height", "103");
+
+    // Force a back navigation back to this page.
+    window.location.href = ""
+}
+
+function onImg2Load()
+{
+    img2 = document.getElementById('imgToReplace2');
+    testPassed("Image2 loaded");
+    shouldBe("img2.width", "76");
+    shouldBe("img2.height", "103");
+
+    finishJSTest();
+}
+
+function moveMouseToCenterOfElement(element)
+{
+    var centerX = element.offsetLeft + element.offsetWidth / 2;
+    var centerY = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(centerX, centerY);
+}
+
+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");
+
+        debug("Reuse the previous blobURL");
+        img2 = document.getElementById('imgToReplace2');
+        img2._onload_ = onImg2Load;
+        evalAndLog("img2.src = ""
+    }
+}, 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);
+
+window.addEventListener('load', function() {
+    eventSender.beginDragWithFiles(['../files/resources/abe.png']);
+    moveMouseToCenterOfElement(document.getElementById('file'));
+    eventSender.mouseUp();
+}, false);
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (180645 => 180646)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2015-02-25 23:42:38 UTC (rev 180645)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2015-02-25 23:49:08 UTC (rev 180646)
@@ -640,6 +640,7 @@
 fast/forms/file/input-file-re-render.html
 fast/forms/file/recover-file-input-in-unposted-form.html
 fast/forms/file/selected-files-from-history-state.html
+fast/history/page-cache-createObjectURL.html
 fast/workers/worker-copy-shared-blob-url.html
 http/tests/local/fileapi/file-last-modified-after-delete.html
 http/tests/local/fileapi/file-last-modified.html

Modified: trunk/Source/WebCore/ChangeLog (180645 => 180646)


--- trunk/Source/WebCore/ChangeLog	2015-02-25 23:42:38 UTC (rev 180645)
+++ trunk/Source/WebCore/ChangeLog	2015-02-25 23:49:08 UTC (rev 180646)
@@ -1,3 +1,26 @@
+2015-02-25  Chris Dumez  <cdu...@apple.com>
+
+        Make PublicURLManager suspendable
+        https://bugs.webkit.org/show_bug.cgi?id=141977
+        <rdar://problem/19923085>
+
+        Reviewed by Andreas Kling.
+
+        Make PublicURLManager suspendable by overriding ActiveDOMObject::canSuspend()
+        and returning true. Nothing prevents suspending the PublicURLManager as its
+        implementation never causes JS to be executed. No implementation for
+        suspend() / resume() needs to be provided for the same reason.
+
+        The fact that PublicURLManager wasn't suspendable was preventing pages using
+        URL.createObjectURL() from entering the PageCache. Baidu.com search results
+        pages are using the API for example.
+
+        Test: fast/history/page-cache-createObjectURL.html
+
+        * html/PublicURLManager.cpp:
+        (WebCore::PublicURLManager::canSuspend):
+        * html/PublicURLManager.h:
+
 2015-02-25  Zalan Bujtas  <za...@apple.com>
 
         Cleanup BackgroundImageGeometry class.

Modified: trunk/Source/WebCore/html/PublicURLManager.cpp (180645 => 180646)


--- trunk/Source/WebCore/html/PublicURLManager.cpp	2015-02-25 23:42:38 UTC (rev 180645)
+++ trunk/Source/WebCore/html/PublicURLManager.cpp	2015-02-25 23:49:08 UTC (rev 180646)
@@ -80,4 +80,10 @@
     m_registryToURL.clear();
 }
 
+bool PublicURLManager::canSuspend() const
+{
+    // Suspending an PublicURLManager is safe as it does not cause any JS to be executed.
+    return true;
 }
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/html/PublicURLManager.h (180645 => 180646)


--- trunk/Source/WebCore/html/PublicURLManager.h	2015-02-25 23:42:38 UTC (rev 180645)
+++ trunk/Source/WebCore/html/PublicURLManager.h	2015-02-25 23:49:08 UTC (rev 180646)
@@ -52,6 +52,8 @@
 
     // ActiveDOMObject interface.
     virtual void stop() override;
+    virtual bool canSuspend() const override;
+
 private:
     virtual const char* activeDOMObjectName() const override { return "PublicURLManager"; }
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to