Title: [248276] trunk
Revision
248276
Author
[email protected]
Date
2019-08-05 16:00:26 -0700 (Mon, 05 Aug 2019)

Log Message

navigator.geolocation wrapper should not become GC-collectable once its frame is detached
https://bugs.webkit.org/show_bug.cgi?id=200436

Reviewed by Darin Adler.

Source/WebCore:

navigator.geolocation wrapper should not become GC-collectable once its frame is detached, given
that it can outlive the frame. Instead, tie the navigator.geolocation wrapper's lifetime to its
Navigator's.

Test: fast/dom/navigator-property-gc-after-frame-detach.html

* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::create):
(WebCore::Geolocation::Geolocation):
(WebCore::Geolocation::navigator):
(WebCore::Geolocation::frame const):
* Modules/geolocation/Geolocation.h:
* Modules/geolocation/Geolocation.idl:
* Modules/geolocation/NavigatorGeolocation.cpp:
(WebCore::NavigatorGeolocation::NavigatorGeolocation):
(WebCore::NavigatorGeolocation::from):
(WebCore::NavigatorGeolocation::geolocation):
(WebCore::NavigatorGeolocation::geolocation const):
* Modules/geolocation/NavigatorGeolocation.h:
* bindings/js/JSNavigatorCustom.cpp:
(WebCore::JSNavigator::visitAdditionalChildren):
* bindings/js/JSWorkerNavigatorCustom.cpp:
(WebCore::JSWorkerNavigator::visitAdditionalChildren):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/IDLAttributes.json:
* page/Navigator.cpp:
(WebCore::Navigator::plugins):
(WebCore::Navigator::mimeTypes):
* page/NavigatorBase.h:
* plugins/DOMMimeTypeArray.cpp:
(WebCore::DOMMimeTypeArray::DOMMimeTypeArray):
* plugins/DOMMimeTypeArray.h:
* plugins/DOMMimeTypeArray.idl:
* plugins/DOMPluginArray.cpp:
(WebCore::DOMPluginArray::DOMPluginArray):
* plugins/DOMPluginArray.h:
* plugins/DOMPluginArray.idl:
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerContainer.idl:

LayoutTests:

Add layout test coverage.

* fast/dom/navigator-property-gc-after-frame-detach-expected.txt: Added.
* fast/dom/navigator-property-gc-after-frame-detach.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (248275 => 248276)


--- trunk/LayoutTests/ChangeLog	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/LayoutTests/ChangeLog	2019-08-05 23:00:26 UTC (rev 248276)
@@ -1,3 +1,15 @@
+2019-08-05  Chris Dumez  <[email protected]>
+
+        navigator.geolocation wrapper should not become GC-collectable once its frame is detached
+        https://bugs.webkit.org/show_bug.cgi?id=200436
+
+        Reviewed by Darin Adler.
+
+        Add layout test coverage.
+
+        * fast/dom/navigator-property-gc-after-frame-detach-expected.txt: Added.
+        * fast/dom/navigator-property-gc-after-frame-detach.html: Added.
+
 2019-08-05  Devin Rousso  <[email protected]>
 
         Web Inspector: rename "Stylesheet" to "Style Sheet" to match spec text

Added: trunk/LayoutTests/fast/dom/navigator-property-gc-after-frame-detach-expected.txt (0 => 248276)


--- trunk/LayoutTests/fast/dom/navigator-property-gc-after-frame-detach-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/navigator-property-gc-after-frame-detach-expected.txt	2019-08-05 23:00:26 UTC (rev 248276)
@@ -0,0 +1,23 @@
+Tests that Navigator properties do not get GC'd before their Navigator object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+PASS frameNavigator.serviceWorker.foo is 1
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+PASS frameNavigator.serviceWorker.foo is 1
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+PASS frameNavigator.serviceWorker.foo is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/navigator-property-gc-after-frame-detach.html (0 => 248276)


--- trunk/LayoutTests/fast/dom/navigator-property-gc-after-frame-detach.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/navigator-property-gc-after-frame-detach.html	2019-08-05 23:00:26 UTC (rev 248276)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<iframe id="testFrame" src=""
+<script>
+description("Tests that Navigator properties do not get GC'd before their Navigator object.");
+jsTestIsAsync = true;
+
+var navigatorProperties = [ "geolocation", "mimeTypes", "plugins" ];
+if (navigator.serviceWorker)
+    navigatorProperties.push("serviceWorker");
+
+_onload_ = function() {
+    frameNavigator = document.getElementById("testFrame").contentWindow.navigator;
+    for (let navigatorProperty of navigatorProperties)
+        eval("frameNavigator." + navigatorProperty + ".foo = 1;");
+    document.getElementById("testFrame").remove();
+    for (let navigatorProperty of navigatorProperties)
+        shouldBe("frameNavigator." + navigatorProperty + ".foo", "1");
+    debug("");
+    gc();
+    for (let navigatorProperty of navigatorProperties)
+        shouldBe("frameNavigator." + navigatorProperty + ".foo", "1");
+    debug("");
+    setTimeout(() => {
+        gc();
+        for (let navigatorProperty of navigatorProperties)
+            shouldBe("frameNavigator." + navigatorProperty + ".foo", "1");
+        finishJSTest();
+    }, 10);
+}
+</script>
+</body>

Added: trunk/LayoutTests/platform/mac-wk1/fast/dom/navigator-property-gc-after-frame-detach-expected.txt (0 => 248276)


--- trunk/LayoutTests/platform/mac-wk1/fast/dom/navigator-property-gc-after-frame-detach-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/fast/dom/navigator-property-gc-after-frame-detach-expected.txt	2019-08-05 23:00:26 UTC (rev 248276)
@@ -0,0 +1,20 @@
+Tests that Navigator properties do not get GC'd before their Navigator object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/win/fast/dom/navigator-property-gc-after-frame-detach-expected.txt (0 => 248276)


--- trunk/LayoutTests/platform/win/fast/dom/navigator-property-gc-after-frame-detach-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/win/fast/dom/navigator-property-gc-after-frame-detach-expected.txt	2019-08-05 23:00:26 UTC (rev 248276)
@@ -0,0 +1,20 @@
+Tests that Navigator properties do not get GC'd before their Navigator object.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+
+PASS frameNavigator.geolocation.foo is 1
+PASS frameNavigator.mimeTypes.foo is 1
+PASS frameNavigator.plugins.foo is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (248275 => 248276)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2019-08-05 23:00:26 UTC (rev 248276)
@@ -160,8 +160,6 @@
 
 webkit.org/b/105952 fast/loader/submit-form-while-parsing-2.html [ Pass Failure ]
 
-webkit.org/b/141122 editing/selection/programmatic-selection-on-mac-is-directionless.html [ Pass Failure ]
-
 webkit.org/b/149087 http/tests/cache/disk-cache/disk-cache-cancel.html [ Pass Failure ]
 
 http/tests/appcache/decide-navigation-policy-after-delay.html [ Pass ]

Modified: trunk/Source/WebCore/ChangeLog (248275 => 248276)


--- trunk/Source/WebCore/ChangeLog	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/ChangeLog	2019-08-05 23:00:26 UTC (rev 248276)
@@ -1,3 +1,51 @@
+2019-08-05  Chris Dumez  <[email protected]>
+
+        navigator.geolocation wrapper should not become GC-collectable once its frame is detached
+        https://bugs.webkit.org/show_bug.cgi?id=200436
+
+        Reviewed by Darin Adler.
+
+        navigator.geolocation wrapper should not become GC-collectable once its frame is detached, given
+        that it can outlive the frame. Instead, tie the navigator.geolocation wrapper's lifetime to its
+        Navigator's.
+
+        Test: fast/dom/navigator-property-gc-after-frame-detach.html
+
+        * Modules/geolocation/Geolocation.cpp:
+        (WebCore::Geolocation::create):
+        (WebCore::Geolocation::Geolocation):
+        (WebCore::Geolocation::navigator):
+        (WebCore::Geolocation::frame const):
+        * Modules/geolocation/Geolocation.h:
+        * Modules/geolocation/Geolocation.idl:
+        * Modules/geolocation/NavigatorGeolocation.cpp:
+        (WebCore::NavigatorGeolocation::NavigatorGeolocation):
+        (WebCore::NavigatorGeolocation::from):
+        (WebCore::NavigatorGeolocation::geolocation):
+        (WebCore::NavigatorGeolocation::geolocation const):
+        * Modules/geolocation/NavigatorGeolocation.h:
+        * bindings/js/JSNavigatorCustom.cpp:
+        (WebCore::JSNavigator::visitAdditionalChildren):
+        * bindings/js/JSWorkerNavigatorCustom.cpp:
+        (WebCore::JSWorkerNavigator::visitAdditionalChildren):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/IDLAttributes.json:
+        * page/Navigator.cpp:
+        (WebCore::Navigator::plugins):
+        (WebCore::Navigator::mimeTypes):
+        * page/NavigatorBase.h:
+        * plugins/DOMMimeTypeArray.cpp:
+        (WebCore::DOMMimeTypeArray::DOMMimeTypeArray):
+        * plugins/DOMMimeTypeArray.h:
+        * plugins/DOMMimeTypeArray.idl:
+        * plugins/DOMPluginArray.cpp:
+        (WebCore::DOMPluginArray::DOMPluginArray):
+        * plugins/DOMPluginArray.h:
+        * plugins/DOMPluginArray.idl:
+        * workers/service/ServiceWorkerContainer.h:
+        * workers/service/ServiceWorkerContainer.idl:
+
 2019-08-05  Andy Estes  <[email protected]>
 
         [WebIDL] Support partial dictionaries and conditional dictionary members

Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp (248275 => 248276)


--- trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -38,6 +38,7 @@
 #include "GeolocationError.h"
 #include "GeolocationPosition.h"
 #include "Geoposition.h"
+#include "Navigator.h"
 #include "Page.h"
 #include "PositionError.h"
 #include "RuntimeApplicationChecks.h"
@@ -129,18 +130,16 @@
     copy = copyToVector(m_idToNotifierMap.values());
 }
 
-Ref<Geolocation> Geolocation::create(ScriptExecutionContext* context)
+Ref<Geolocation> Geolocation::create(Navigator& navigator)
 {
-    auto geolocation = adoptRef(*new Geolocation(context));
+    auto geolocation = adoptRef(*new Geolocation(navigator));
     geolocation.get().suspendIfNeeded();
     return geolocation;
 }
 
-Geolocation::Geolocation(ScriptExecutionContext* context)
-    : ActiveDOMObject(context)
-    , m_allowGeolocation(Unknown)
-    , m_isSuspended(false)
-    , m_hasChangedPosition(false)
+Geolocation::Geolocation(Navigator& navigator)
+    : ActiveDOMObject(navigator.scriptExecutionContext())
+    , m_navigator(makeWeakPtr(navigator))
     , m_resumeTimer(*this, &Geolocation::resumeTimerFired)
 {
 }
@@ -731,6 +730,16 @@
     }
 }
 
+Navigator* Geolocation::navigator()
+{
+    return m_navigator.get();
+}
+
+Frame* Geolocation::frame() const
+{
+    return m_navigator ? m_navigator->frame() : nullptr;
+}
+
 } // namespace WebCore
                                                         
 #endif // ENABLE(GEOLOCATION)

Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.h (248275 => 248276)


--- trunk/Source/WebCore/Modules/geolocation/Geolocation.h	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.h	2019-08-05 23:00:26 UTC (rev 248276)
@@ -45,6 +45,7 @@
 class Frame;
 class GeoNotifier;
 class GeolocationError;
+class Navigator;
 class Page;
 class ScriptExecutionContext;
 class SecurityOrigin;
@@ -54,12 +55,11 @@
     WTF_MAKE_ISO_ALLOCATED(Geolocation);
     friend class GeoNotifier;
 public:
-    static Ref<Geolocation> create(ScriptExecutionContext*);
+    static Ref<Geolocation> create(Navigator&);
     WEBCORE_EXPORT ~Geolocation();
 
     WEBCORE_EXPORT void resetAllGeolocationPermission();
     Document* document() const { return downcast<Document>(scriptExecutionContext()); }
-    Frame* frame() const { return document() ? document()->frame() : nullptr; }
 
     void getCurrentPosition(Ref<PositionCallback>&&, RefPtr<PositionErrorCallback>&&, PositionOptions&&);
     int watchPosition(Ref<PositionCallback>&&, RefPtr<PositionErrorCallback>&&, PositionOptions&&);
@@ -73,8 +73,11 @@
     void setError(GeolocationError&);
     bool shouldBlockGeolocationRequests();
 
+    Navigator* navigator();
+    WEBCORE_EXPORT Frame* frame() const;
+
 private:
-    explicit Geolocation(ScriptExecutionContext*);
+    explicit Geolocation(Navigator&);
 
     Geoposition* lastPosition();
 
@@ -144,25 +147,20 @@
     bool haveSuitableCachedPosition(const PositionOptions&);
     void makeCachedPositionCallbacks();
 
+    void resumeTimerFired();
+
+    WeakPtr<Navigator> m_navigator;
     GeoNotifierSet m_oneShots;
     Watchers m_watchers;
     GeoNotifierSet m_pendingForPermissionNotifiers;
     RefPtr<Geoposition> m_lastPosition;
 
-    enum {
-        Unknown,
-        InProgress,
-        Yes,
-        No
-    } m_allowGeolocation;
-    bool m_isSuspended;
-    bool m_resetOnResume;
-    bool m_hasChangedPosition;
+    enum { Unknown, InProgress, Yes, No } m_allowGeolocation { Unknown };
+    bool m_isSuspended { false };
+    bool m_resetOnResume { false };
+    bool m_hasChangedPosition { false };
     RefPtr<PositionError> m_errorWaitingForResume;
-
-    void resumeTimerFired();
     Timer m_resumeTimer;
-
     GeoNotifierSet m_requestsAwaitingCachedPosition;
 };
     

Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.idl (248275 => 248276)


--- trunk/Source/WebCore/Modules/geolocation/Geolocation.idl	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.idl	2019-08-05 23:00:26 UTC (rev 248276)
@@ -27,7 +27,7 @@
 [
     NoInterfaceObject,
     Conditional=GEOLOCATION, 
-    GenerateIsReachable=ImplFrame,
+    GenerateIsReachable=ReachableFromNavigator,
 ] interface Geolocation {
     // FIXME: PositionErrorCallback should not be nullable
     void getCurrentPosition(PositionCallback successCallback,

Modified: trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp (248275 => 248276)


--- trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -34,8 +34,8 @@
 
 namespace WebCore {
 
-NavigatorGeolocation::NavigatorGeolocation(DOMWindow* window)
-    : DOMWindowProperty(window)
+NavigatorGeolocation::NavigatorGeolocation(Navigator& navigator)
+    : m_navigator(navigator)
 {
 }
 
@@ -46,13 +46,13 @@
     return "NavigatorGeolocation";
 }
 
-NavigatorGeolocation* NavigatorGeolocation::from(Navigator* navigator)
+NavigatorGeolocation* NavigatorGeolocation::from(Navigator& navigator)
 {
-    NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(navigator, supplementName()));
+    NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(&navigator, supplementName()));
     if (!supplement) {
-        auto newSupplement = std::make_unique<NavigatorGeolocation>(navigator->window());
+        auto newSupplement = std::make_unique<NavigatorGeolocation>(navigator);
         supplement = newSupplement.get();
-        provideTo(navigator, supplementName(), WTFMove(newSupplement));
+        provideTo(&navigator, supplementName(), WTFMove(newSupplement));
     }
     return supplement;
 }
@@ -67,13 +67,13 @@
 
 Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator)
 {
-    return NavigatorGeolocation::from(&navigator)->geolocation();
+    return NavigatorGeolocation::from(navigator)->geolocation();
 }
 
 Geolocation* NavigatorGeolocation::geolocation() const
 {
     if (!m_geolocation)
-        m_geolocation = Geolocation::create(window() ? window()->document() : nullptr);
+        m_geolocation = Geolocation::create(m_navigator);
     return m_geolocation.get();
 }
 

Modified: trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h (248275 => 248276)


--- trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h	2019-08-05 23:00:26 UTC (rev 248276)
@@ -29,12 +29,12 @@
 class Geolocation;
 class Navigator;
 
-class NavigatorGeolocation : public Supplement<Navigator>, public DOMWindowProperty {
+class NavigatorGeolocation : public Supplement<Navigator> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit NavigatorGeolocation(DOMWindow*);
+    explicit NavigatorGeolocation(Navigator&);
     virtual ~NavigatorGeolocation();
-    static NavigatorGeolocation* from(Navigator*);
+    static NavigatorGeolocation* from(Navigator&);
 
     static Geolocation* geolocation(Navigator&);
     Geolocation* geolocation() const;
@@ -47,6 +47,7 @@
     static const char* supplementName();
 
     mutable RefPtr<Geolocation> m_geolocation;
+    Navigator& m_navigator;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSNavigatorCustom.cpp (248275 => 248276)


--- trunk/Source/WebCore/bindings/js/JSNavigatorCustom.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/bindings/js/JSNavigatorCustom.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -30,11 +30,7 @@
 
 void JSNavigator::visitAdditionalChildren(JSC::SlotVisitor& visitor)
 {
-#if ENABLE(SERVICE_WORKER)
-    visitor.addOpaqueRoot(wrapped().serviceWorkerIfExists());
-#else
-    UNUSED_PARAM(visitor);
-#endif
+    visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped()));
 }
 
 }

Modified: trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp (248275 => 248276)


--- trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -30,11 +30,7 @@
 
 void JSWorkerNavigator::visitAdditionalChildren(JSC::SlotVisitor& visitor)
 {
-#if ENABLE(SERVICE_WORKER)
-    visitor.addOpaqueRoot(wrapped().serviceWorkerIfExists());
-#else
-    UNUSED_PARAM(visitor);
-#endif
+    visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped()));
 }
 
 }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (248275 => 248276)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2019-08-05 23:00:26 UTC (rev 248276)
@@ -4690,18 +4690,20 @@
                 $rootString  = "    WebGLRenderingContextBase* root = WTF::getPtr(js${interfaceName}->wrapped().context());\n";
                 $rootString .= "    if (UNLIKELY(reason))\n";
                 $rootString .= "        *reason = \"Reachable from ${interfaceName}\";\n";
-            } elsif (GetGenerateIsReachable($interface) eq "ImplFrame") {
-                $rootString  = "    Frame* root = WTF::getPtr(js${interfaceName}->wrapped().frame());\n";
+            } elsif (GetGenerateIsReachable($interface) eq "ReachableFromDOMWindow") {
+                $rootString  = "    auto* root = WTF::getPtr(js${interfaceName}->wrapped().window());\n";
                 $rootString .= "    if (!root)\n";
                 $rootString .= "        return false;\n";
                 $rootString .= "    if (UNLIKELY(reason))\n";
-                $rootString .= "        *reason = \"Reachable from Frame\";\n";
-            } elsif (GetGenerateIsReachable($interface) eq "ReachableFromDOMWindow") {
-                $rootString  = "    auto* root = WTF::getPtr(js${interfaceName}->wrapped().window());\n";
+                $rootString .= "        *reason = \"Reachable from Window\";\n";
+            } elsif (GetGenerateIsReachable($interface) eq "ReachableFromNavigator") {
+                $implIncludes{"Navigator.h"} = 1;
+                $implIncludes{"WorkerNavigator.h"} = 1;
+                $rootString  = "    NavigatorBase* root = WTF::getPtr(js${interfaceName}->wrapped().navigator());\n";
                 $rootString .= "    if (!root)\n";
                 $rootString .= "        return false;\n";
                 $rootString .= "    if (UNLIKELY(reason))\n";
-                $rootString .= "        *reason = \"Reachable from Window\";\n";
+                $rootString .= "        *reason = \"Reachable from Navigator\";\n";
             } elsif (GetGenerateIsReachable($interface) eq "ImplDocument") {
                 $rootString  = "    Document* root = WTF::getPtr(js${interfaceName}->wrapped().document());\n";
                 $rootString .= "    if (!root)\n";

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (248275 => 248276)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2019-08-05 23:00:26 UTC (rev 248276)
@@ -226,7 +226,7 @@
         },
         "GenerateIsReachable": {
             "contextsAllowed": ["interface"],
-            "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplDocument", "ImplElementRoot", "ImplFrame", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow"]
+            "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplDocument", "ImplElementRoot", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow", "ReachableFromNavigator"]
         },
         "Global": {
             "contextsAllowed": ["interface"],

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (248275 => 248276)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -2050,7 +2050,7 @@
     // FIXME: Can we remove the PLATFORM(IOS_FAMILY)-guard?
 #if ENABLE(GEOLOCATION) && PLATFORM(IOS_FAMILY)
     if (m_navigator)
-        NavigatorGeolocation::from(m_navigator.get())->resetAllGeolocationPermission();
+        NavigatorGeolocation::from(*m_navigator)->resetAllGeolocationPermission();
 #endif
 }
 

Modified: trunk/Source/WebCore/page/Navigator.cpp (248275 => 248276)


--- trunk/Source/WebCore/page/Navigator.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/page/Navigator.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -153,7 +153,7 @@
             ResourceLoadObserver::shared().logNavigatorAPIAccessed(*frame->document(), ResourceLoadStatistics::NavigatorAPI::Plugins);
     }
     if (!m_plugins)
-        m_plugins = DOMPluginArray::create(window());
+        m_plugins = DOMPluginArray::create(*this);
     return *m_plugins;
 }
 
@@ -164,7 +164,7 @@
             ResourceLoadObserver::shared().logNavigatorAPIAccessed(*frame->document(), ResourceLoadStatistics::NavigatorAPI::MimeTypes);
     }
     if (!m_mimeTypes)
-        m_mimeTypes = DOMMimeTypeArray::create(window());
+        m_mimeTypes = DOMMimeTypeArray::create(*this);
     return *m_mimeTypes;
 }
 

Modified: trunk/Source/WebCore/page/NavigatorBase.h (248275 => 248276)


--- trunk/Source/WebCore/page/NavigatorBase.h	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/page/NavigatorBase.h	2019-08-05 23:00:26 UTC (rev 248276)
@@ -31,6 +31,7 @@
 #include <wtf/RefCounted.h>
 #include <wtf/UniqueRef.h>
 #include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -37,7 +38,7 @@
 class ScriptExecutionContext;
 class ServiceWorkerContainer;
 
-class NavigatorBase : public RefCounted<NavigatorBase>, public ContextDestructionObserver {
+class NavigatorBase : public RefCounted<NavigatorBase>, public ContextDestructionObserver, public CanMakeWeakPtr<NavigatorBase> {
 public:
     virtual ~NavigatorBase();
 

Modified: trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp (248275 => 248276)


--- trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -31,8 +31,8 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(DOMMimeTypeArray);
 
-DOMMimeTypeArray::DOMMimeTypeArray(DOMWindow* window)
-    : DOMWindowProperty(window)
+DOMMimeTypeArray::DOMMimeTypeArray(Navigator& navigator)
+    : m_navigator(makeWeakPtr(navigator))
 {
 }
 

Modified: trunk/Source/WebCore/plugins/DOMMimeTypeArray.h (248275 => 248276)


--- trunk/Source/WebCore/plugins/DOMMimeTypeArray.h	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/plugins/DOMMimeTypeArray.h	2019-08-05 23:00:26 UTC (rev 248276)
@@ -21,7 +21,7 @@
 #pragma once
 
 #include "DOMMimeType.h"
-#include "DOMWindowProperty.h"
+#include "Navigator.h"
 #include "ScriptWrappable.h"
 #include <wtf/RefCounted.h>
 
@@ -29,10 +29,10 @@
 
 class PluginData;
 
-class DOMMimeTypeArray final : public ScriptWrappable, public RefCounted<DOMMimeTypeArray>, public DOMWindowProperty {
+class DOMMimeTypeArray final : public ScriptWrappable, public RefCounted<DOMMimeTypeArray> {
     WTF_MAKE_ISO_ALLOCATED(DOMMimeTypeArray);
 public:
-    static Ref<DOMMimeTypeArray> create(DOMWindow* window) { return adoptRef(*new DOMMimeTypeArray(window)); }
+    static Ref<DOMMimeTypeArray> create(Navigator& navigator) { return adoptRef(*new DOMMimeTypeArray(navigator)); }
     ~DOMMimeTypeArray();
 
     unsigned length() const;
@@ -39,10 +39,15 @@
     RefPtr<DOMMimeType> item(unsigned index);
     RefPtr<DOMMimeType> namedItem(const AtomString& propertyName);
     Vector<AtomString> supportedPropertyNames();
+    
+    Navigator* navigator() { return m_navigator.get(); }
 
 private:
-    explicit DOMMimeTypeArray(DOMWindow*);
+    explicit DOMMimeTypeArray(Navigator&);
     PluginData* getPluginData() const;
+    Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; }
+    
+    WeakPtr<Navigator> m_navigator;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/plugins/DOMMimeTypeArray.idl (248275 => 248276)


--- trunk/Source/WebCore/plugins/DOMMimeTypeArray.idl	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/plugins/DOMMimeTypeArray.idl	2019-08-05 23:00:26 UTC (rev 248276)
@@ -19,7 +19,7 @@
 */
 
 [
-    GenerateIsReachable=ReachableFromDOMWindow,
+    GenerateIsReachable=ReachableFromNavigator,
     LegacyUnenumerableNamedProperties,
     ImplementationLacksVTable,
     InterfaceName=MimeTypeArray,

Modified: trunk/Source/WebCore/plugins/DOMPluginArray.cpp (248275 => 248276)


--- trunk/Source/WebCore/plugins/DOMPluginArray.cpp	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/plugins/DOMPluginArray.cpp	2019-08-05 23:00:26 UTC (rev 248276)
@@ -31,8 +31,8 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(DOMPluginArray);
 
-DOMPluginArray::DOMPluginArray(DOMWindow* window)
-    : DOMWindowProperty(window)
+DOMPluginArray::DOMPluginArray(Navigator& navigator)
+    : m_navigator(makeWeakPtr(navigator))
 {
 }
 

Modified: trunk/Source/WebCore/plugins/DOMPluginArray.h (248275 => 248276)


--- trunk/Source/WebCore/plugins/DOMPluginArray.h	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/plugins/DOMPluginArray.h	2019-08-05 23:00:26 UTC (rev 248276)
@@ -22,6 +22,7 @@
 
 #include "DOMPlugin.h"
 #include "DOMWindowProperty.h"
+#include "Navigator.h"
 #include "ScriptWrappable.h"
 #include <wtf/RefCounted.h>
 
@@ -29,10 +30,10 @@
 
 class PluginData;
 
-class DOMPluginArray final : public ScriptWrappable, public RefCounted<DOMPluginArray>, public DOMWindowProperty {
+class DOMPluginArray final : public ScriptWrappable, public RefCounted<DOMPluginArray> {
     WTF_MAKE_ISO_ALLOCATED(DOMPluginArray);
 public:
-    static Ref<DOMPluginArray> create(DOMWindow* window) { return adoptRef(*new DOMPluginArray(window)); }
+    static Ref<DOMPluginArray> create(Navigator& navigator) { return adoptRef(*new DOMPluginArray(navigator)); }
     ~DOMPluginArray();
 
     unsigned length() const;
@@ -41,10 +42,16 @@
     Vector<AtomString> supportedPropertyNames();
 
     void refresh(bool reloadPages);
+    
+    Navigator* navigator() { return m_navigator.get(); }
 
 private:
-    explicit DOMPluginArray(DOMWindow*);
+    explicit DOMPluginArray(Navigator&);
+
     PluginData* pluginData() const;
+    Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; }
+    
+    WeakPtr<Navigator> m_navigator;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/plugins/DOMPluginArray.idl (248275 => 248276)


--- trunk/Source/WebCore/plugins/DOMPluginArray.idl	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/plugins/DOMPluginArray.idl	2019-08-05 23:00:26 UTC (rev 248276)
@@ -19,7 +19,7 @@
 */
 
 [
-    GenerateIsReachable=ReachableFromDOMWindow,
+    GenerateIsReachable=ReachableFromNavigator,
     LegacyUnenumerableNamedProperties,
     ImplementationLacksVTable,
     InterfaceName=PluginArray,

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (248275 => 248276)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2019-08-05 23:00:26 UTC (rev 248276)
@@ -87,6 +87,8 @@
 
     bool isAlwaysOnLoggingAllowed() const;
 
+    NavigatorBase* navigator() { return &m_navigator; }
+
 private:
     void scheduleJob(std::unique_ptr<ServiceWorkerJob>&&);
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl (248275 => 248276)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl	2019-08-05 22:52:17 UTC (rev 248275)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl	2019-08-05 23:00:26 UTC (rev 248276)
@@ -31,7 +31,7 @@
     Exposed=(Window,ServiceWorker),
     Conditional=SERVICE_WORKER,
     EnabledAtRuntime=ServiceWorker,
-    GenerateIsReachable=Impl,
+    GenerateIsReachable=ReachableFromNavigator
 ] interface ServiceWorkerContainer : EventTarget {
     readonly attribute ServiceWorker? controller;
     readonly attribute Promise<ServiceWorkerRegistration> ready;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to