Geolocation objects shouldn't prevent page caching.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jan 2015 23:14:24 +0000 (23:14 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jan 2015 23:14:24 +0000 (23:14 +0000)
<https://webkit.org/b/140369>

Reviewed by Joseph Pecoraro.

Source/WebCore:

Enable the code for suspend/resume of Geolocation objects on all platforms
instead of just iOS. This allows pages using geolocation to use page cache
instead of reloading on back/forward navigation.

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

* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::Geolocation):
(WebCore::Geolocation::resetAllGeolocationPermission):
(WebCore::Geolocation::stop):
(WebCore::Geolocation::setIsAllowed):
(WebCore::Geolocation::positionChanged):
(WebCore::Geolocation::setError):
* Modules/geolocation/Geolocation.h:

LayoutTests:

Take the existing test for this and make it not-specific-to-iOS.
Also remove a test whose only purpose was confirming that we don't cache these pages.

* fast/dom/Geolocation/no-page-cache-expected.txt: Removed.
* fast/dom/Geolocation/no-page-cache.html: Removed.
* fast/dom/Geolocation/script-tests/no-page-cache.js: Removed.
* fast/history/page-cache-geolocation-expected.txt: Renamed from LayoutTests/platform/ios-simulator/ios/fast/history/page-cache-geolocation-expected.txt.
* fast/history/page-cache-geolocation.html: Renamed from LayoutTests/platform/ios-simulator/ios/fast/history/script-tests/page-cache-geolocation.js.
* fast/history/resources/page-cache-helper.html: Added.
* platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation-expected.txt: Removed.
* platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation.html: Removed.
* platform/ios-sim-deprecated/iphone/fast/history/script-tests/page-cache-geolocation.js: Removed.
* platform/ios-simulator/TestExpectations:
* platform/ios-simulator/ios/fast/history/page-cache-geolocation.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178300 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Geolocation/no-page-cache-expected.txt [deleted file]
LayoutTests/fast/dom/Geolocation/no-page-cache.html [deleted file]
LayoutTests/fast/dom/Geolocation/script-tests/no-page-cache.js [deleted file]
LayoutTests/fast/history/page-cache-geolocation-expected.txt [moved from LayoutTests/platform/ios-simulator/ios/fast/history/page-cache-geolocation-expected.txt with 100% similarity]
LayoutTests/fast/history/page-cache-geolocation.html [moved from LayoutTests/platform/ios-simulator/ios/fast/history/script-tests/page-cache-geolocation.js with 85% similarity]
LayoutTests/fast/history/resources/page-cache-helper.html [new file with mode: 0644]
LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation-expected.txt [deleted file]
LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation.html [deleted file]
LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/script-tests/page-cache-geolocation.js [deleted file]
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/ios-simulator/ios/fast/history/page-cache-geolocation.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/Modules/geolocation/Geolocation.cpp
Source/WebCore/Modules/geolocation/Geolocation.h

index 0cff219..28d83e3 100644 (file)
@@ -1,3 +1,25 @@
+2015-01-12  Andreas Kling  <akling@apple.com>
+
+        Geolocation objects shouldn't prevent page caching.
+        <https://webkit.org/b/140369>
+
+        Reviewed by Joseph Pecoraro.
+
+        Take the existing test for this and make it not-specific-to-iOS.
+        Also remove a test whose only purpose was confirming that we don't cache these pages.
+
+        * fast/dom/Geolocation/no-page-cache-expected.txt: Removed.
+        * fast/dom/Geolocation/no-page-cache.html: Removed.
+        * fast/dom/Geolocation/script-tests/no-page-cache.js: Removed.
+        * fast/history/page-cache-geolocation-expected.txt: Renamed from LayoutTests/platform/ios-simulator/ios/fast/history/page-cache-geolocation-expected.txt.
+        * fast/history/page-cache-geolocation.html: Renamed from LayoutTests/platform/ios-simulator/ios/fast/history/script-tests/page-cache-geolocation.js.
+        * fast/history/resources/page-cache-helper.html: Added.
+        * platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation-expected.txt: Removed.
+        * platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation.html: Removed.
+        * platform/ios-sim-deprecated/iphone/fast/history/script-tests/page-cache-geolocation.js: Removed.
+        * platform/ios-simulator/TestExpectations:
+        * platform/ios-simulator/ios/fast/history/page-cache-geolocation.html: Removed.
+
 2015-01-12  Manuel Rego Casasnovas  <rego@igalia.com>
 
         Make fast/css/first-letter-skip-out-of-flow.html a ref-test
diff --git a/LayoutTests/fast/dom/Geolocation/no-page-cache-expected.txt b/LayoutTests/fast/dom/Geolocation/no-page-cache-expected.txt
deleted file mode 100644 (file)
index 66cbe1b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Tests that pages that use Geolocation are not put in the page cache.
-
-Currently, Geolocation does not work with the page cache so pages that use Geolocation are explicitly prevented from entering the cache. This test checks for accidental enabling of the page Cache for Geolocation. See https://bugs.webkit.org/show_bug.cgi?id=43956 for details.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Main page opening resources/cached-page-1.html
-resources/cached-page-1.html fired, count = 1
-resources/cached-page-1.html about to navigate to resources/cached-page-2.html
-resources/cached-page-2.html about to go back to resources/cached-page-1.html
-resources/cached-page-1.html fired, count = 2
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/Geolocation/no-page-cache.html b/LayoutTests/fast/dom/Geolocation/no-page-cache.html
deleted file mode 100644 (file)
index 5d10d91..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../../resources/js-test-pre.js"></script>
-</head>
-<body>
-<script src="script-tests/no-page-cache.js"></script>
-<script src="../../../resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/fast/dom/Geolocation/script-tests/no-page-cache.js b/LayoutTests/fast/dom/Geolocation/script-tests/no-page-cache.js
deleted file mode 100644 (file)
index 204bdea..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-description("Tests that pages that use Geolocation are not put in the page cache.<br><br>Currently, Geolocation does not work with the page cache so pages that use Geolocation are explicitly prevented from entering the cache. This test checks for accidental enabling of the page Cache for Geolocation. See https://bugs.webkit.org/show_bug.cgi?id=43956 for details.");
-
-if (window.testRunner) {
-    testRunner.waitUntilDone();
-    testRunner.setCanOpenWindows();
-    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
-} else
-    debug('This test can not be run without the testRunner');
-
-var pageOneOnloadCount = 0;
-function reportPageOneOnload() {
-    ++pageOneOnloadCount;
-    debug('resources/cached-page-1.html fired, count = ' + pageOneOnloadCount);
-    if (pageOneOnloadCount == 2) {
-        finishJSTest();
-    }
-    return pageOneOnloadCount;
-}
-
-debug("Main page opening resources/cached-page-1.html");
-window.open("resources/cached-page-1.html");
-
-window.jsTestIsAsync = true;
@@ -1,3 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
 description('Tests that a page that makes use of simple geolocation can use the page cache.');
 
 window.addEventListener("pageshow", function(event) {
@@ -38,3 +47,6 @@ window.addEventListener('load', function() {
 
 var successfullyParsed = true;
 var jsTestIsAsync = true;
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/history/resources/page-cache-helper.html b/LayoutTests/fast/history/resources/page-cache-helper.html
new file mode 100644 (file)
index 0000000..3a0f771
--- /dev/null
@@ -0,0 +1,9 @@
+This page should go back. If a test outputs the contents of this
+page, then the test page failed to enter the page cache.
+<script>
+  window.addEventListener("load", function() {
+    setTimeout(function() {
+      history.back();
+    }, 0);
+  }, false);
+</script>
diff --git a/LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation-expected.txt b/LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation-expected.txt
deleted file mode 100644 (file)
index cd2855c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-CONSOLE MESSAGE: line 1: TypeError: HTMLParagraphElement is not a function (evaluating 'description('Tests that a page that makes use of simple geolocation can use the page cache.')')
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x0
-      RenderBlock {DIV} at (0,0) size 784x0
diff --git a/LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation.html b/LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/page-cache-geolocation.html
deleted file mode 100644 (file)
index 7d61306..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<link rel="stylesheet" href="../../../../../fast/js/resources/js-test-style.css">
-<script src="../../../../../fast/js/resources/js-test-pre.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script src="script-tests/page-cache-geolocation.js"></script>
-<script src="../../../../../fast/js/resources/js-test-post-function.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/script-tests/page-cache-geolocation.js b/LayoutTests/platform/ios-sim-deprecated/iphone/fast/history/script-tests/page-cache-geolocation.js
deleted file mode 100644 (file)
index 6a6c39e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-description('Tests that a page that makes use of simple geolocation can use the page cache.');
-
-window.addEventListener("pageshow", function(event) {
-    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
-    if (event.persisted) {
-        debug("PASS - Page did enter and was restored from the page cache");
-        finishJSTest();
-        window.testRunner.notifyDone();
-    }
-}, false);
-
-window.addEventListener("pagehide", function(event) {
-    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
-    if (!event.persisted) {
-        debug("FAIL - Page did not enter the page cache.");
-        finishJSTest();
-        window.testRunner.notifyDone();
-    }
-}, false);
-
-window.addEventListener('load', function() {
-
-    // Enable the PageCache and make this an async test.
-    if (window.testRunner) {
-        window.testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
-        window.testRunner.waitUntilDone();
-    }
-
-    // Access geolocation. It is enough to create the geolocation object.
-    debug(navigator.geolocation);
-
-    // Force a back navigation back to this page.
-    setTimeout(function() {
-        window.location.href = "resources/page-cache-helper.html";
-    }, 0);
-
-}, false);
-
-var successfullyParsed = true;
-var jsTestIsAsync = true;
index b9b633c..4fbbb01 100644 (file)
@@ -2401,7 +2401,6 @@ fast/dom/DeviceOrientation/no-page-cache.html
 fast/dom/DeviceOrientation/no-synchronous-events.html
 fast/dom/DeviceOrientation/null-values.html
 fast/dom/DeviceOrientation/updates.html
-fast/dom/Geolocation/no-page-cache.html
 fast/dom/HTMLLinkElement/link-and-subresource-test-nonexistent.html
 fast/dom/HTMLLinkElement/link-and-subresource-test.html
 fast/dom/HTMLLinkElement/prefetch-onerror.html
diff --git a/LayoutTests/platform/ios-simulator/ios/fast/history/page-cache-geolocation.html b/LayoutTests/platform/ios-simulator/ios/fast/history/page-cache-geolocation.html
deleted file mode 100644 (file)
index 7dc5a5b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../../../../resources/js-test-pre.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script src="script-tests/page-cache-geolocation.js"></script>
-</body>
-</html>
index 2f5c549..7f00d0c 100644 (file)
@@ -1,3 +1,25 @@
+2015-01-12  Andreas Kling  <akling@apple.com>
+
+        Geolocation objects shouldn't prevent page caching.
+        <https://webkit.org/b/140369>
+
+        Reviewed by Joseph Pecoraro.
+
+        Enable the code for suspend/resume of Geolocation objects on all platforms
+        instead of just iOS. This allows pages using geolocation to use page cache
+        instead of reloading on back/forward navigation.
+
+        Test: fast/history/page-cache-geolocation.html
+
+        * Modules/geolocation/Geolocation.cpp:
+        (WebCore::Geolocation::Geolocation):
+        (WebCore::Geolocation::resetAllGeolocationPermission):
+        (WebCore::Geolocation::stop):
+        (WebCore::Geolocation::setIsAllowed):
+        (WebCore::Geolocation::positionChanged):
+        (WebCore::Geolocation::setError):
+        * Modules/geolocation/Geolocation.h:
+
 2015-01-12  Chris Dumez  <cdumez@apple.com>
 
         Log navigation types using DiagnosticLoggingClient
index d0f8a93..25a3f7b 100644 (file)
@@ -235,11 +235,9 @@ Ref<Geolocation> Geolocation::create(ScriptExecutionContext* context)
 Geolocation::Geolocation(ScriptExecutionContext* context)
     : ActiveDOMObject(context)
     , m_allowGeolocation(Unknown)
-#if PLATFORM(IOS)
     , m_isSuspended(false)
     , m_hasChangedPosition(false)
     , m_resumeTimer(*this, &Geolocation::resumeTimerFired)
-#endif
 {
 }
 
@@ -263,7 +261,6 @@ Page* Geolocation::page() const
     return document() ? document()->page() : nullptr;
 }
 
-#if PLATFORM(IOS)
 bool Geolocation::canSuspend() const
 {
     return !hasListeners();
@@ -378,7 +375,6 @@ void Geolocation::resetAllGeolocationPermission()
     for (size_t i = 0; i < watcherCopy.size(); ++i)
         startRequest(watcherCopy[i].get());
 }
-#endif // PLATFORM(IOS)
 
 void Geolocation::stop()
 {
@@ -389,10 +385,8 @@ void Geolocation::stop()
     m_allowGeolocation = Unknown;
     cancelAllRequests();
     stopUpdating();
-#if PLATFORM(IOS)
     m_hasChangedPosition = false;
     m_errorWaitingForResume = nullptr;
-#endif // PLATFORM(IOS)
     m_pendingForPermissionNotifiers.clear();
 }
 
@@ -555,10 +549,8 @@ void Geolocation::setIsAllowed(bool allowed)
     // position.
     m_allowGeolocation = allowed ? Yes : No;
     
-#if PLATFORM(IOS)
     if (m_isSuspended)
         return;
-#endif
 
     // Permission request was made during the startRequest process
     if (!m_pendingForPermissionNotifiers.isEmpty()) {
@@ -572,10 +564,8 @@ void Geolocation::setIsAllowed(bool allowed)
         error->setIsFatal(true);
         handleError(error.get());
         m_requestsAwaitingCachedPosition.clear();
-#if PLATFORM(IOS)
         m_hasChangedPosition = false;
         m_errorWaitingForResume = nullptr;
-#endif
 
         return;
     }
@@ -756,24 +746,20 @@ void Geolocation::positionChanged()
     // Stop all currently running timers.
     stopTimers();
 
-#if PLATFORM(IOS)
     if (m_isSuspended) {
         m_hasChangedPosition = true;
         return;
     }
-#endif
 
     makeSuccessCallbacks();
 }
 
 void Geolocation::setError(GeolocationError* error)
 {
-#if PLATFORM(IOS)
     if (m_isSuspended) {
         m_errorWaitingForResume = createPositionError(error);
         return;
     }
-#endif
     RefPtr<PositionError> positionError = createPositionError(error);
     handleError(positionError.get());
 }
index 383e309..afbe33a 100644 (file)
@@ -54,12 +54,10 @@ public:
     static Ref<Geolocation> create(ScriptExecutionContext*);
     WEBCORE_EXPORT ~Geolocation();
 
-#if PLATFORM(IOS)
     virtual bool canSuspend() const override;
     virtual void suspend(ReasonForSuspension) override;
     virtual void resume() override;
     WEBCORE_EXPORT void resetAllGeolocationPermission();
-#endif // PLATFORM(IOS)
     Document* document() const;
     WEBCORE_EXPORT Frame* frame() const;
 
@@ -182,7 +180,6 @@ private:
         Yes,
         No
     } m_allowGeolocation;
-#if PLATFORM(IOS)
     bool m_isSuspended;
     bool m_resetOnResume;
     bool m_hasChangedPosition;
@@ -190,7 +187,6 @@ private:
 
     void resumeTimerFired();
     Timer m_resumeTimer;
-#endif // PLATFORM(IOS)
 
     GeoNotifierSet m_requestsAwaitingCachedPosition;
 };