Changeset 248276 in webkit
- Timestamp:
- Aug 5, 2019, 4:00:26 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 23 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/navigator-property-gc-after-frame-detach-expected.txt (added)
-
LayoutTests/fast/dom/navigator-property-gc-after-frame-detach.html (added)
-
LayoutTests/platform/mac-wk1/fast/dom/navigator-property-gc-after-frame-detach-expected.txt (added)
-
LayoutTests/platform/win/fast/dom/navigator-property-gc-after-frame-detach-expected.txt (added)
-
LayoutTests/platform/wk2/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/geolocation/Geolocation.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/geolocation/Geolocation.h (modified) (5 diffs)
-
Source/WebCore/Modules/geolocation/Geolocation.idl (modified) (1 diff)
-
Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp (modified) (4 diffs)
-
Source/WebCore/Modules/geolocation/NavigatorGeolocation.h (modified) (2 diffs)
-
Source/WebCore/bindings/js/JSNavigatorCustom.cpp (modified) (1 diff)
-
Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp (modified) (1 diff)
-
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (modified) (2 diffs)
-
Source/WebCore/bindings/scripts/IDLAttributes.json (modified) (1 diff)
-
Source/WebCore/page/DOMWindow.cpp (modified) (1 diff)
-
Source/WebCore/page/Navigator.cpp (modified) (2 diffs)
-
Source/WebCore/page/NavigatorBase.h (modified) (2 diffs)
-
Source/WebCore/plugins/DOMMimeTypeArray.cpp (modified) (1 diff)
-
Source/WebCore/plugins/DOMMimeTypeArray.h (modified) (3 diffs)
-
Source/WebCore/plugins/DOMMimeTypeArray.idl (modified) (1 diff)
-
Source/WebCore/plugins/DOMPluginArray.cpp (modified) (1 diff)
-
Source/WebCore/plugins/DOMPluginArray.h (modified) (3 diffs)
-
Source/WebCore/plugins/DOMPluginArray.idl (modified) (1 diff)
-
Source/WebCore/workers/service/ServiceWorkerContainer.h (modified) (1 diff)
-
Source/WebCore/workers/service/ServiceWorkerContainer.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r248274 r248276 1 2019-08-05 Chris Dumez <cdumez@apple.com> 2 3 navigator.geolocation wrapper should not become GC-collectable once its frame is detached 4 https://bugs.webkit.org/show_bug.cgi?id=200436 5 6 Reviewed by Darin Adler. 7 8 Add layout test coverage. 9 10 * fast/dom/navigator-property-gc-after-frame-detach-expected.txt: Added. 11 * fast/dom/navigator-property-gc-after-frame-detach.html: Added. 12 1 13 2019-08-05 Devin Rousso <drousso@apple.com> 2 14 -
trunk/LayoutTests/platform/wk2/TestExpectations
r248273 r248276 160 160 161 161 webkit.org/b/105952 fast/loader/submit-form-while-parsing-2.html [ Pass Failure ] 162 163 webkit.org/b/141122 editing/selection/programmatic-selection-on-mac-is-directionless.html [ Pass Failure ]164 162 165 163 webkit.org/b/149087 http/tests/cache/disk-cache/disk-cache-cancel.html [ Pass Failure ] -
trunk/Source/WebCore/ChangeLog
r248275 r248276 1 2019-08-05 Chris Dumez <cdumez@apple.com> 2 3 navigator.geolocation wrapper should not become GC-collectable once its frame is detached 4 https://bugs.webkit.org/show_bug.cgi?id=200436 5 6 Reviewed by Darin Adler. 7 8 navigator.geolocation wrapper should not become GC-collectable once its frame is detached, given 9 that it can outlive the frame. Instead, tie the navigator.geolocation wrapper's lifetime to its 10 Navigator's. 11 12 Test: fast/dom/navigator-property-gc-after-frame-detach.html 13 14 * Modules/geolocation/Geolocation.cpp: 15 (WebCore::Geolocation::create): 16 (WebCore::Geolocation::Geolocation): 17 (WebCore::Geolocation::navigator): 18 (WebCore::Geolocation::frame const): 19 * Modules/geolocation/Geolocation.h: 20 * Modules/geolocation/Geolocation.idl: 21 * Modules/geolocation/NavigatorGeolocation.cpp: 22 (WebCore::NavigatorGeolocation::NavigatorGeolocation): 23 (WebCore::NavigatorGeolocation::from): 24 (WebCore::NavigatorGeolocation::geolocation): 25 (WebCore::NavigatorGeolocation::geolocation const): 26 * Modules/geolocation/NavigatorGeolocation.h: 27 * bindings/js/JSNavigatorCustom.cpp: 28 (WebCore::JSNavigator::visitAdditionalChildren): 29 * bindings/js/JSWorkerNavigatorCustom.cpp: 30 (WebCore::JSWorkerNavigator::visitAdditionalChildren): 31 * bindings/scripts/CodeGeneratorJS.pm: 32 (GenerateImplementation): 33 * bindings/scripts/IDLAttributes.json: 34 * page/Navigator.cpp: 35 (WebCore::Navigator::plugins): 36 (WebCore::Navigator::mimeTypes): 37 * page/NavigatorBase.h: 38 * plugins/DOMMimeTypeArray.cpp: 39 (WebCore::DOMMimeTypeArray::DOMMimeTypeArray): 40 * plugins/DOMMimeTypeArray.h: 41 * plugins/DOMMimeTypeArray.idl: 42 * plugins/DOMPluginArray.cpp: 43 (WebCore::DOMPluginArray::DOMPluginArray): 44 * plugins/DOMPluginArray.h: 45 * plugins/DOMPluginArray.idl: 46 * workers/service/ServiceWorkerContainer.h: 47 * workers/service/ServiceWorkerContainer.idl: 48 1 49 2019-08-05 Andy Estes <aestes@apple.com> 2 50 -
trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp
r243887 r248276 39 39 #include "GeolocationPosition.h" 40 40 #include "Geoposition.h" 41 #include "Navigator.h" 41 42 #include "Page.h" 42 43 #include "PositionError.h" … … 130 131 } 131 132 132 Ref<Geolocation> Geolocation::create( ScriptExecutionContext* context)133 { 134 auto geolocation = adoptRef(*new Geolocation( context));133 Ref<Geolocation> Geolocation::create(Navigator& navigator) 134 { 135 auto geolocation = adoptRef(*new Geolocation(navigator)); 135 136 geolocation.get().suspendIfNeeded(); 136 137 return geolocation; 137 138 } 138 139 139 Geolocation::Geolocation(ScriptExecutionContext* context) 140 : ActiveDOMObject(context) 141 , m_allowGeolocation(Unknown) 142 , m_isSuspended(false) 143 , m_hasChangedPosition(false) 140 Geolocation::Geolocation(Navigator& navigator) 141 : ActiveDOMObject(navigator.scriptExecutionContext()) 142 , m_navigator(makeWeakPtr(navigator)) 144 143 , m_resumeTimer(*this, &Geolocation::resumeTimerFired) 145 144 { … … 732 731 } 733 732 733 Navigator* Geolocation::navigator() 734 { 735 return m_navigator.get(); 736 } 737 738 Frame* Geolocation::frame() const 739 { 740 return m_navigator ? m_navigator->frame() : nullptr; 741 } 742 734 743 } // namespace WebCore 735 744 -
trunk/Source/WebCore/Modules/geolocation/Geolocation.h
r243887 r248276 46 46 class GeoNotifier; 47 47 class GeolocationError; 48 class Navigator; 48 49 class Page; 49 50 class ScriptExecutionContext; … … 55 56 friend class GeoNotifier; 56 57 public: 57 static Ref<Geolocation> create( ScriptExecutionContext*);58 static Ref<Geolocation> create(Navigator&); 58 59 WEBCORE_EXPORT ~Geolocation(); 59 60 60 61 WEBCORE_EXPORT void resetAllGeolocationPermission(); 61 62 Document* document() const { return downcast<Document>(scriptExecutionContext()); } 62 Frame* frame() const { return document() ? document()->frame() : nullptr; }63 63 64 64 void getCurrentPosition(Ref<PositionCallback>&&, RefPtr<PositionErrorCallback>&&, PositionOptions&&); … … 74 74 bool shouldBlockGeolocationRequests(); 75 75 76 Navigator* navigator(); 77 WEBCORE_EXPORT Frame* frame() const; 78 76 79 private: 77 explicit Geolocation( ScriptExecutionContext*);80 explicit Geolocation(Navigator&); 78 81 79 82 Geoposition* lastPosition(); … … 145 148 void makeCachedPositionCallbacks(); 146 149 150 void resumeTimerFired(); 151 152 WeakPtr<Navigator> m_navigator; 147 153 GeoNotifierSet m_oneShots; 148 154 Watchers m_watchers; … … 150 156 RefPtr<Geoposition> m_lastPosition; 151 157 152 enum { 153 Unknown, 154 InProgress, 155 Yes, 156 No 157 } m_allowGeolocation; 158 bool m_isSuspended; 159 bool m_resetOnResume; 160 bool m_hasChangedPosition; 158 enum { Unknown, InProgress, Yes, No } m_allowGeolocation { Unknown }; 159 bool m_isSuspended { false }; 160 bool m_resetOnResume { false }; 161 bool m_hasChangedPosition { false }; 161 162 RefPtr<PositionError> m_errorWaitingForResume; 162 163 void resumeTimerFired();164 163 Timer m_resumeTimer; 165 166 164 GeoNotifierSet m_requestsAwaitingCachedPosition; 167 165 }; -
trunk/Source/WebCore/Modules/geolocation/Geolocation.idl
r209669 r248276 28 28 NoInterfaceObject, 29 29 Conditional=GEOLOCATION, 30 GenerateIsReachable= ImplFrame,30 GenerateIsReachable=ReachableFromNavigator, 31 31 ] interface Geolocation { 32 32 // FIXME: PositionErrorCallback should not be nullable -
trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp
r237266 r248276 35 35 namespace WebCore { 36 36 37 NavigatorGeolocation::NavigatorGeolocation( DOMWindow* window)38 : DOMWindowProperty(window)37 NavigatorGeolocation::NavigatorGeolocation(Navigator& navigator) 38 : m_navigator(navigator) 39 39 { 40 40 } … … 47 47 } 48 48 49 NavigatorGeolocation* NavigatorGeolocation::from(Navigator *navigator)49 NavigatorGeolocation* NavigatorGeolocation::from(Navigator& navigator) 50 50 { 51 NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from( navigator, supplementName()));51 NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(&navigator, supplementName())); 52 52 if (!supplement) { 53 auto newSupplement = std::make_unique<NavigatorGeolocation>(navigator ->window());53 auto newSupplement = std::make_unique<NavigatorGeolocation>(navigator); 54 54 supplement = newSupplement.get(); 55 provideTo( navigator, supplementName(), WTFMove(newSupplement));55 provideTo(&navigator, supplementName(), WTFMove(newSupplement)); 56 56 } 57 57 return supplement; … … 68 68 Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator) 69 69 { 70 return NavigatorGeolocation::from( &navigator)->geolocation();70 return NavigatorGeolocation::from(navigator)->geolocation(); 71 71 } 72 72 … … 74 74 { 75 75 if (!m_geolocation) 76 m_geolocation = Geolocation::create( window() ? window()->document() : nullptr);76 m_geolocation = Geolocation::create(m_navigator); 77 77 return m_geolocation.get(); 78 78 } -
trunk/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h
r237266 r248276 30 30 class Navigator; 31 31 32 class NavigatorGeolocation : public Supplement<Navigator> , public DOMWindowProperty{32 class NavigatorGeolocation : public Supplement<Navigator> { 33 33 WTF_MAKE_FAST_ALLOCATED; 34 34 public: 35 explicit NavigatorGeolocation( DOMWindow*);35 explicit NavigatorGeolocation(Navigator&); 36 36 virtual ~NavigatorGeolocation(); 37 static NavigatorGeolocation* from(Navigator *);37 static NavigatorGeolocation* from(Navigator&); 38 38 39 39 static Geolocation* geolocation(Navigator&); … … 48 48 49 49 mutable RefPtr<Geolocation> m_geolocation; 50 Navigator& m_navigator; 50 51 }; 51 52 -
trunk/Source/WebCore/bindings/js/JSNavigatorCustom.cpp
r244043 r248276 31 31 void JSNavigator::visitAdditionalChildren(JSC::SlotVisitor& visitor) 32 32 { 33 #if ENABLE(SERVICE_WORKER) 34 visitor.addOpaqueRoot(wrapped().serviceWorkerIfExists()); 35 #else 36 UNUSED_PARAM(visitor); 37 #endif 33 visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped())); 38 34 } 39 35 -
trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp
r244043 r248276 31 31 void JSWorkerNavigator::visitAdditionalChildren(JSC::SlotVisitor& visitor) 32 32 { 33 #if ENABLE(SERVICE_WORKER) 34 visitor.addOpaqueRoot(wrapped().serviceWorkerIfExists()); 35 #else 36 UNUSED_PARAM(visitor); 37 #endif 33 visitor.addOpaqueRoot(static_cast<NavigatorBase*>(&wrapped())); 38 34 } 39 35 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r248275 r248276 4691 4691 $rootString .= " if (UNLIKELY(reason))\n"; 4692 4692 $rootString .= " *reason = \"Reachable from ${interfaceName}\";\n"; 4693 } elsif (GetGenerateIsReachable($interface) eq "ImplFrame") {4694 $rootString = " Frame* root = WTF::getPtr(js${interfaceName}->wrapped().frame());\n";4695 $rootString .= " if (!root)\n";4696 $rootString .= " return false;\n";4697 $rootString .= " if (UNLIKELY(reason))\n";4698 $rootString .= " *reason = \"Reachable from Frame\";\n";4699 4693 } elsif (GetGenerateIsReachable($interface) eq "ReachableFromDOMWindow") { 4700 4694 $rootString = " auto* root = WTF::getPtr(js${interfaceName}->wrapped().window());\n"; … … 4703 4697 $rootString .= " if (UNLIKELY(reason))\n"; 4704 4698 $rootString .= " *reason = \"Reachable from Window\";\n"; 4699 } elsif (GetGenerateIsReachable($interface) eq "ReachableFromNavigator") { 4700 $implIncludes{"Navigator.h"} = 1; 4701 $implIncludes{"WorkerNavigator.h"} = 1; 4702 $rootString = " NavigatorBase* root = WTF::getPtr(js${interfaceName}->wrapped().navigator());\n"; 4703 $rootString .= " if (!root)\n"; 4704 $rootString .= " return false;\n"; 4705 $rootString .= " if (UNLIKELY(reason))\n"; 4706 $rootString .= " *reason = \"Reachable from Navigator\";\n"; 4705 4707 } elsif (GetGenerateIsReachable($interface) eq "ImplDocument") { 4706 4708 $rootString = " Document* root = WTF::getPtr(js${interfaceName}->wrapped().document());\n"; -
trunk/Source/WebCore/bindings/scripts/IDLAttributes.json
r248155 r248276 227 227 "GenerateIsReachable": { 228 228 "contextsAllowed": ["interface"], 229 "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplDocument", "ImplElementRoot", "Impl Frame", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow"]229 "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplDocument", "ImplElementRoot", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow", "ReachableFromNavigator"] 230 230 }, 231 231 "Global": { -
trunk/Source/WebCore/page/DOMWindow.cpp
r248193 r248276 2051 2051 #if ENABLE(GEOLOCATION) && PLATFORM(IOS_FAMILY) 2052 2052 if (m_navigator) 2053 NavigatorGeolocation::from( m_navigator.get())->resetAllGeolocationPermission();2053 NavigatorGeolocation::from(*m_navigator)->resetAllGeolocationPermission(); 2054 2054 #endif 2055 2055 } -
trunk/Source/WebCore/page/Navigator.cpp
r244927 r248276 154 154 } 155 155 if (!m_plugins) 156 m_plugins = DOMPluginArray::create( window());156 m_plugins = DOMPluginArray::create(*this); 157 157 return *m_plugins; 158 158 } … … 165 165 } 166 166 if (!m_mimeTypes) 167 m_mimeTypes = DOMMimeTypeArray::create( window());167 m_mimeTypes = DOMMimeTypeArray::create(*this); 168 168 return *m_mimeTypes; 169 169 } -
trunk/Source/WebCore/page/NavigatorBase.h
r244927 r248276 32 32 #include <wtf/UniqueRef.h> 33 33 #include <wtf/Vector.h> 34 #include <wtf/WeakPtr.h> 34 35 35 36 namespace WebCore { … … 38 39 class ServiceWorkerContainer; 39 40 40 class NavigatorBase : public RefCounted<NavigatorBase>, public ContextDestructionObserver {41 class NavigatorBase : public RefCounted<NavigatorBase>, public ContextDestructionObserver, public CanMakeWeakPtr<NavigatorBase> { 41 42 public: 42 43 virtual ~NavigatorBase(); -
trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp
r246490 r248276 32 32 WTF_MAKE_ISO_ALLOCATED_IMPL(DOMMimeTypeArray); 33 33 34 DOMMimeTypeArray::DOMMimeTypeArray( DOMWindow* window)35 : DOMWindowProperty(window)34 DOMMimeTypeArray::DOMMimeTypeArray(Navigator& navigator) 35 : m_navigator(makeWeakPtr(navigator)) 36 36 { 37 37 } -
trunk/Source/WebCore/plugins/DOMMimeTypeArray.h
r246490 r248276 22 22 23 23 #include "DOMMimeType.h" 24 #include " DOMWindowProperty.h"24 #include "Navigator.h" 25 25 #include "ScriptWrappable.h" 26 26 #include <wtf/RefCounted.h> … … 30 30 class PluginData; 31 31 32 class DOMMimeTypeArray final : public ScriptWrappable, public RefCounted<DOMMimeTypeArray> , public DOMWindowProperty{32 class DOMMimeTypeArray final : public ScriptWrappable, public RefCounted<DOMMimeTypeArray> { 33 33 WTF_MAKE_ISO_ALLOCATED(DOMMimeTypeArray); 34 34 public: 35 static Ref<DOMMimeTypeArray> create( DOMWindow* window) { return adoptRef(*new DOMMimeTypeArray(window)); }35 static Ref<DOMMimeTypeArray> create(Navigator& navigator) { return adoptRef(*new DOMMimeTypeArray(navigator)); } 36 36 ~DOMMimeTypeArray(); 37 37 … … 40 40 RefPtr<DOMMimeType> namedItem(const AtomString& propertyName); 41 41 Vector<AtomString> supportedPropertyNames(); 42 43 Navigator* navigator() { return m_navigator.get(); } 42 44 43 45 private: 44 explicit DOMMimeTypeArray( DOMWindow*);46 explicit DOMMimeTypeArray(Navigator&); 45 47 PluginData* getPluginData() const; 48 Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; } 49 50 WeakPtr<Navigator> m_navigator; 46 51 }; 47 52 -
trunk/Source/WebCore/plugins/DOMMimeTypeArray.idl
r248155 r248276 20 20 21 21 [ 22 GenerateIsReachable=ReachableFrom DOMWindow,22 GenerateIsReachable=ReachableFromNavigator, 23 23 LegacyUnenumerableNamedProperties, 24 24 ImplementationLacksVTable, -
trunk/Source/WebCore/plugins/DOMPluginArray.cpp
r246490 r248276 32 32 WTF_MAKE_ISO_ALLOCATED_IMPL(DOMPluginArray); 33 33 34 DOMPluginArray::DOMPluginArray( DOMWindow* window)35 : DOMWindowProperty(window)34 DOMPluginArray::DOMPluginArray(Navigator& navigator) 35 : m_navigator(makeWeakPtr(navigator)) 36 36 { 37 37 } -
trunk/Source/WebCore/plugins/DOMPluginArray.h
r246490 r248276 23 23 #include "DOMPlugin.h" 24 24 #include "DOMWindowProperty.h" 25 #include "Navigator.h" 25 26 #include "ScriptWrappable.h" 26 27 #include <wtf/RefCounted.h> … … 30 31 class PluginData; 31 32 32 class DOMPluginArray final : public ScriptWrappable, public RefCounted<DOMPluginArray> , public DOMWindowProperty{33 class DOMPluginArray final : public ScriptWrappable, public RefCounted<DOMPluginArray> { 33 34 WTF_MAKE_ISO_ALLOCATED(DOMPluginArray); 34 35 public: 35 static Ref<DOMPluginArray> create( DOMWindow* window) { return adoptRef(*new DOMPluginArray(window)); }36 static Ref<DOMPluginArray> create(Navigator& navigator) { return adoptRef(*new DOMPluginArray(navigator)); } 36 37 ~DOMPluginArray(); 37 38 … … 42 43 43 44 void refresh(bool reloadPages); 45 46 Navigator* navigator() { return m_navigator.get(); } 44 47 45 48 private: 46 explicit DOMPluginArray(DOMWindow*); 49 explicit DOMPluginArray(Navigator&); 50 47 51 PluginData* pluginData() const; 52 Frame* frame() const { return m_navigator ? m_navigator->frame() : nullptr; } 53 54 WeakPtr<Navigator> m_navigator; 48 55 }; 49 56 -
trunk/Source/WebCore/plugins/DOMPluginArray.idl
r248155 r248276 20 20 21 21 [ 22 GenerateIsReachable=ReachableFrom DOMWindow,22 GenerateIsReachable=ReachableFromNavigator, 23 23 LegacyUnenumerableNamedProperties, 24 24 ImplementationLacksVTable, -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h
r245873 r248276 88 88 bool isAlwaysOnLoggingAllowed() const; 89 89 90 NavigatorBase* navigator() { return &m_navigator; } 91 90 92 private: 91 93 void scheduleJob(std::unique_ptr<ServiceWorkerJob>&&); -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl
r225221 r248276 32 32 Conditional=SERVICE_WORKER, 33 33 EnabledAtRuntime=ServiceWorker, 34 GenerateIsReachable= Impl,34 GenerateIsReachable=ReachableFromNavigator 35 35 ] interface ServiceWorkerContainer : EventTarget { 36 36 readonly attribute ServiceWorker? controller;
Note:
See TracChangeset
for help on using the changeset viewer.