Changeset 241899 in webkit
- Timestamp:
- Feb 21, 2019 1:34:26 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r241868 r241899 1 2019-02-21 Tim Horton <timothy_horton@apple.com> 2 3 Crash under RemoteLayerTreePropertyApplier::applyProperties when reattaching to old process 4 https://bugs.webkit.org/show_bug.cgi?id=194845 5 <rdar://problem/47944579> 6 7 Reviewed by Antti Koivisto. 8 9 New test: ProcessSwap.PageOverlayLayerPersistence 10 11 * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h: 12 (WebKit::RemoteLayerTreeTransaction::LayerProperties::notePropertiesChanged): 13 Keep track of all properties that have ever changed on a layer, so we 14 can re-send them if a layer moves between contexts. 15 16 * WebProcess/WebPage/DrawingArea.cpp: 17 (WebKit::DrawingArea::~DrawingArea): 18 (WebKit::DrawingArea::removeMessageReceiverIfNeeded): 19 * WebProcess/WebPage/DrawingArea.h: 20 (WebKit::DrawingArea::layerHostDidFlushLayers): 21 Make it possible to tear down DrawingArea's MessageReceiver before it is destroyed, 22 so that we can keep two DrawingAreas alive in a single process for a short time. 23 24 (WebKit::DrawingArea::adoptLayersFromDrawingArea): 25 Add adoptLayersFromDrawingArea; see below for its only useful implementation. 26 27 * WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.cpp: 28 (WebKit::GraphicsLayerCARemote::GraphicsLayerCARemote): 29 (WebKit::GraphicsLayerCARemote::~GraphicsLayerCARemote): 30 (WebKit::GraphicsLayerCARemote::createPlatformCALayer): 31 (WebKit::GraphicsLayerCARemote::createPlatformCALayerForEmbeddedView): 32 (WebKit::GraphicsLayerCARemote::moveToContext): 33 * WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.h: 34 Make it possible to move a GraphicsLayerCARemote between RemoteLayerTreeContexts. 35 36 * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp: 37 (WebKit::PlatformCALayerRemote::create): 38 (WebKit::PlatformCALayerRemote::createForEmbeddedView): 39 (WebKit::PlatformCALayerRemote::~PlatformCALayerRemote): 40 (WebKit::PlatformCALayerRemote::moveToContext): 41 * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h: 42 * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm: 43 (WebKit::PlatformCALayerRemoteCustom::create): 44 (WebKit::PlatformCALayerRemoteCustom::clone const): 45 Make it possible to move a PlatformCALayerRemote between RemoteLayerTreeContexts. 46 47 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h: 48 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm: 49 (WebKit::RemoteLayerTreeContext::~RemoteLayerTreeContext): 50 (WebKit::RemoteLayerTreeContext::adoptLayersFromContext): 51 (WebKit::RemoteLayerTreeContext::layerDidEnterContext): 52 (WebKit::RemoteLayerTreeContext::layerWillLeaveContext): 53 (WebKit::RemoteLayerTreeContext::graphicsLayerDidEnterContext): 54 (WebKit::RemoteLayerTreeContext::graphicsLayerWillLeaveContext): 55 (WebKit::RemoteLayerTreeContext::layerWasCreated): Deleted. 56 (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed): Deleted. 57 Keep track of all GraphicsLayerCARemote instances in the context, like we 58 do for PlatformCALayerRemote, so that we can update their context backpointers if needed. 59 60 Also make it possible to move all outstanding layers to a new context. 61 62 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h: 63 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm: 64 (WebKit::RemoteLayerTreeDrawingArea::adoptLayersFromDrawingArea): 65 * WebProcess/WebPage/WebPage.cpp: 66 (WebKit::WebPage::reinitializeWebPage): 67 When doing a DrawingArea swap, transition all layers from the old context 68 to the new one. In order to do this, we temporarily keep both DrawingAreas 69 alive, but make use of the new mechanism to remove the old one's MessageReceiver 70 before installing the new one, so that destroying the old one later doesn't 71 remove it (avoiding re-introducing bug 189481). 72 1 73 2019-02-21 Chris Dumez <cdumez@apple.com> 2 74 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h
r239427 r241899 120 120 { 121 121 changedProperties.add(changeFlags); 122 everChangedProperties.add(changeFlags); 122 123 } 123 124 … … 128 129 129 130 OptionSet<LayerChange> changedProperties; 131 OptionSet<LayerChange> everChangedProperties; 130 132 131 133 String name; -
trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.cpp
r237266 r241899 79 79 DrawingArea::~DrawingArea() 80 80 { 81 WebProcess::singleton().removeMessageReceiver(Messages::DrawingArea::messageReceiverName(), m_webPage.pageID());81 removeMessageReceiverIfNeeded(); 82 82 } 83 83 … … 95 95 #endif 96 96 97 void DrawingArea::removeMessageReceiverIfNeeded() 98 { 99 if (m_hasRemovedMessageReceiver) 100 return; 101 m_hasRemovedMessageReceiver = true; 102 WebProcess::singleton().removeMessageReceiver(Messages::DrawingArea::messageReceiverName(), m_webPage.pageID()); 103 } 104 97 105 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h
r241183 r241899 141 141 #endif 142 142 143 virtual void layerHostDidFlushLayers() { } ;143 virtual void layerHostDidFlushLayers() { } 144 144 145 145 #if USE(COORDINATED_GRAPHICS) … … 150 150 virtual void deviceOrPageScaleFactorChanged() = 0; 151 151 #endif 152 153 virtual void adoptLayersFromDrawingArea(DrawingArea&) { } 154 155 void removeMessageReceiverIfNeeded(); 152 156 153 157 protected: … … 187 191 virtual void destroyNativeSurfaceHandleForCompositing(bool&) = 0; 188 192 #endif 193 194 bool m_hasRemovedMessageReceiver { false }; 189 195 }; 190 196 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.cpp
r238108 r241899 29 29 #include "PlatformCAAnimationRemote.h" 30 30 #include "PlatformCALayerRemote.h" 31 #include "RemoteLayerTreeContext.h" 31 32 #include <WebCore/PlatformScreen.h> 32 33 … … 34 35 using namespace WebCore; 35 36 37 GraphicsLayerCARemote::GraphicsLayerCARemote(Type layerType, GraphicsLayerClient& client, RemoteLayerTreeContext& context) 38 : GraphicsLayerCA(layerType, client) 39 , m_context(&context) 40 { 41 context.graphicsLayerDidEnterContext(*this); 42 } 43 36 44 GraphicsLayerCARemote::~GraphicsLayerCARemote() 37 45 { 46 if (m_context) 47 m_context->graphicsLayerWillLeaveContext(*this); 38 48 } 39 49 … … 45 55 Ref<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* owner) 46 56 { 47 auto result = PlatformCALayerRemote::create(layerType, owner, m_context);57 auto result = PlatformCALayerRemote::create(layerType, owner, *m_context); 48 58 49 59 if (result->canHaveBackingStore()) … … 55 65 Ref<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(PlatformLayer* platformLayer, PlatformCALayerClient* owner) 56 66 { 57 return PlatformCALayerRemote::create(platformLayer, owner, m_context);67 return PlatformCALayerRemote::create(platformLayer, owner, *m_context); 58 68 } 59 69 60 70 Ref<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayerForEmbeddedView(PlatformCALayer::LayerType layerType, GraphicsLayer::EmbeddedViewID embeddedViewID, PlatformCALayerClient* owner) 61 71 { 62 return PlatformCALayerRemote::createForEmbeddedView(layerType, embeddedViewID, owner, m_context);72 return PlatformCALayerRemote::createForEmbeddedView(layerType, embeddedViewID, owner, *m_context); 63 73 } 64 74 … … 68 78 } 69 79 80 void GraphicsLayerCARemote::moveToContext(RemoteLayerTreeContext& context) 81 { 82 if (m_context) 83 m_context->graphicsLayerWillLeaveContext(*this); 84 85 m_context = &context; 86 87 context.graphicsLayerDidEnterContext(*this); 88 } 89 70 90 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.h
r238108 r241899 35 35 class GraphicsLayerCARemote final : public WebCore::GraphicsLayerCA { 36 36 public: 37 GraphicsLayerCARemote(Type layerType, WebCore::GraphicsLayerClient& client, RemoteLayerTreeContext& context) 38 : GraphicsLayerCA(layerType, client) 39 , m_context(context) 40 { 41 } 42 37 GraphicsLayerCARemote(Type layerType, WebCore::GraphicsLayerClient&, RemoteLayerTreeContext&); 43 38 virtual ~GraphicsLayerCARemote(); 44 39 45 40 bool filtersCanBeComposited(const WebCore::FilterOperations& filters) override; 41 42 void moveToContext(RemoteLayerTreeContext&); 43 void clearContext() { m_context = nullptr; } 46 44 47 45 private: … … 56 54 bool shouldDirectlyCompositeImage(WebCore::Image*) const override { return false; } 57 55 58 RemoteLayerTreeContext &m_context;56 RemoteLayerTreeContext* m_context; 59 57 }; 60 58 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp
r238468 r241899 52 52 layer = adoptRef(new PlatformCALayerRemote(layerType, owner, context)); 53 53 54 context.layer WasCreated(*layer, layerType);54 context.layerDidEnterContext(*layer, layerType); 55 55 56 56 return layer.releaseNonNull(); … … 65 65 { 66 66 RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemote(layerType, embeddedViewID, owner, context)); 67 context.layer WasCreated(*layer, layerType);67 context.layerDidEnterContext(*layer, layerType); 68 68 return layer.releaseNonNull(); 69 69 } … … 73 73 auto layer = adoptRef(*new PlatformCALayerRemote(other, owner, context)); 74 74 75 context.layer WasCreated(layer.get(), other.layerType());75 context.layerDidEnterContext(layer.get(), other.layerType()); 76 76 77 77 return layer; … … 117 117 118 118 if (m_context) 119 m_context->layerWillBeDestroyed(*this); 119 m_context->layerWillLeaveContext(*this); 120 } 121 122 void PlatformCALayerRemote::moveToContext(RemoteLayerTreeContext& context) 123 { 124 if (m_context) 125 m_context->layerWillLeaveContext(*this); 126 127 m_context = &context; 128 129 context.layerDidEnterContext(*this, layerType()); 130 131 m_properties.notePropertiesChanged(m_properties.everChangedProperties); 120 132 } 121 133 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h
r238108 r241899 196 196 void didCommit(); 197 197 198 void moveToContext(RemoteLayerTreeContext&); 198 199 void clearContext() { m_context = nullptr; } 199 200 RemoteLayerTreeContext* context() const { return m_context; } -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm
r239709 r241899 49 49 { 50 50 auto layer = adoptRef(*new PlatformCALayerRemoteCustom(PlatformCALayerCocoa::layerTypeForPlatformLayer(platformLayer), platformLayer, owner, context)); 51 context.layer WasCreated(layer.get(), layer->layerType());51 context.layerDidEnterContext(layer.get(), layer->layerType()); 52 52 return WTFMove(layer); 53 53 } … … 127 127 128 128 auto clone = adoptRef(*new PlatformCALayerRemoteCustom(layerType(), clonedLayer.get(), owner, *context())); 129 context()->layer WasCreated(clone.get(), clone->layerType());129 context()->layerDidEnterContext(clone.get(), clone->layerType()); 130 130 131 131 updateClonedLayerProperties(clone.get(), copyContents); -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h
r236016 r241899 36 36 namespace WebKit { 37 37 38 class GraphicsLayerCARemote; 38 39 class PlatformCALayerRemote; 39 40 class WebPage; … … 45 46 ~RemoteLayerTreeContext(); 46 47 47 void layerWasCreated(PlatformCALayerRemote&, WebCore::PlatformCALayer::LayerType); 48 void layerWillBeDestroyed(PlatformCALayerRemote&); 48 void layerDidEnterContext(PlatformCALayerRemote&, WebCore::PlatformCALayer::LayerType); 49 void layerWillLeaveContext(PlatformCALayerRemote&); 50 51 void graphicsLayerDidEnterContext(GraphicsLayerCARemote&); 52 void graphicsLayerWillLeaveContext(GraphicsLayerCARemote&); 49 53 50 54 void backingStoreWasCreated(RemoteLayerBackingStore&); … … 73 77 bool nextFlushIsForImmediatePaint() const { return m_nextFlushIsForImmediatePaint; } 74 78 79 void adoptLayersFromContext(RemoteLayerTreeContext&); 80 75 81 private: 76 82 // WebCore::GraphicsLayerFactory … … 82 88 Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayers; 83 89 84 HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_live Layers;90 HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_livePlatformLayers; 85 91 HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_layersWithAnimations; 92 93 HashSet<GraphicsLayerCARemote*> m_liveGraphicsLayers; 86 94 87 95 RemoteLayerBackingStoreCollection m_backingStoreCollection; -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm
r238108 r241899 50 50 RemoteLayerTreeContext::~RemoteLayerTreeContext() 51 51 { 52 for (auto& layer : m_live Layers.values())52 for (auto& layer : m_livePlatformLayers.values()) 53 53 layer->clearContext(); 54 55 auto graphicsLayers = m_liveGraphicsLayers; 56 for (auto& layer : graphicsLayers) 57 layer->clearContext(); 58 } 59 60 void RemoteLayerTreeContext::adoptLayersFromContext(RemoteLayerTreeContext& oldContext) 61 { 62 auto& platformLayers = oldContext.m_livePlatformLayers; 63 while (!platformLayers.isEmpty()) 64 platformLayers.begin()->value->moveToContext(*this); 65 66 auto& graphicsLayers = oldContext.m_liveGraphicsLayers; 67 while (!graphicsLayers.isEmpty()) 68 (*graphicsLayers.begin())->moveToContext(*this); 54 69 } 55 70 … … 64 79 } 65 80 66 void RemoteLayerTreeContext::layer WasCreated(PlatformCALayerRemote& layer, PlatformCALayer::LayerType type)81 void RemoteLayerTreeContext::layerDidEnterContext(PlatformCALayerRemote& layer, PlatformCALayer::LayerType type) 67 82 { 68 83 GraphicsLayer::PlatformLayerID layerID = layer.layerID(); … … 79 94 80 95 m_createdLayers.add(layerID, WTFMove(creationProperties)); 81 m_live Layers.add(layerID, &layer);96 m_livePlatformLayers.add(layerID, &layer); 82 97 } 83 98 84 void RemoteLayerTreeContext::layerWill BeDestroyed(PlatformCALayerRemote& layer)99 void RemoteLayerTreeContext::layerWillLeaveContext(PlatformCALayerRemote& layer) 85 100 { 86 101 ASSERT(layer.layerID()); … … 88 103 89 104 m_createdLayers.remove(layerID); 90 m_live Layers.remove(layerID);105 m_livePlatformLayers.remove(layerID); 91 106 92 107 ASSERT(!m_destroyedLayers.contains(layerID)); … … 94 109 95 110 m_layersWithAnimations.remove(layerID); 111 } 112 113 void RemoteLayerTreeContext::graphicsLayerDidEnterContext(GraphicsLayerCARemote& layer) 114 { 115 m_liveGraphicsLayers.add(&layer); 116 } 117 118 void RemoteLayerTreeContext::graphicsLayerWillLeaveContext(GraphicsLayerCARemote& layer) 119 { 120 m_liveGraphicsLayers.remove(&layer); 96 121 } 97 122 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
r240940 r241899 124 124 bool markLayersVolatileImmediatelyIfPossible() override; 125 125 126 void adoptLayersFromDrawingArea(DrawingArea&) override; 127 126 128 class BackingStoreFlusher : public ThreadSafeRefCounted<BackingStoreFlusher> { 127 129 public: -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
r241846 r241899 533 533 } 534 534 535 void RemoteLayerTreeDrawingArea::adoptLayersFromDrawingArea(DrawingArea& oldDrawingArea) 536 { 537 RELEASE_ASSERT(oldDrawingArea.type() == type()); 538 539 RemoteLayerTreeDrawingArea& oldRemoteDrawingArea = static_cast<RemoteLayerTreeDrawingArea&>(oldDrawingArea); 540 541 m_remoteLayerTreeContext->adoptLayersFromContext(*oldRemoteDrawingArea.m_remoteLayerTreeContext); 542 } 543 535 544 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r241721 r241899 696 696 697 697 if (m_shouldResetDrawingAreaAfterSuspend) { 698 // Make sure we destroy the previous drawing area before constructing the new one as DrawingArea registers / unregisters 699 // itself as an IPC::MesssageReceiver in its constructor / destructor. 700 m_drawingArea = nullptr; 698 auto oldDrawingArea = std::exchange(m_drawingArea, nullptr); 699 oldDrawingArea->removeMessageReceiverIfNeeded(); 701 700 m_shouldResetDrawingAreaAfterSuspend = false; 702 701 … … 706 705 m_drawingArea->updatePreferences(parameters.store); 707 706 m_drawingArea->setPaintingEnabled(true); 707 708 m_drawingArea->adoptLayersFromDrawingArea(*oldDrawingArea); 709 708 710 unfreezeLayerTree(LayerTreeFreezeReason::PageSuspended); 709 711 } -
trunk/Tools/ChangeLog
r241869 r241899 1 2019-02-21 Tim Horton <timothy_horton@apple.com> 2 3 Crash under RemoteLayerTreePropertyApplier::applyProperties when reattaching to old process 4 https://bugs.webkit.org/show_bug.cgi?id=194845 5 <rdar://problem/47944579> 6 7 Reviewed by Antti Koivisto. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 11 1 12 2019-02-21 Zalan Bujtas <zalan@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r241841 r241899 93 93 2D1C04A71D76298B000A6816 /* TestNavigationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1C04A61D76298B000A6816 /* TestNavigationDelegate.mm */; }; 94 94 2D21FE591F04642900B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D21FE581F04642800B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm */; }; 95 2D3CA3A8221DF4B40088E803 /* PageOverlayPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */; }; 95 96 2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */; }; 96 97 2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; }; … … 1428 1429 2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FixedLayoutSize.mm; sourceTree = "<group>"; }; 1429 1430 2D21FE581F04642800B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFViewStablePresentationUpdateCallback.mm; sourceTree = "<group>"; }; 1431 2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageOverlayPlugin.mm; sourceTree = "<group>"; }; 1430 1432 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKThumbnailView.mm; path = WebKit/WKThumbnailView.mm; sourceTree = "<group>"; }; 1431 1433 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLVideoElementWrapper.mm; sourceTree = "<group>"; }; … … 2559 2561 CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */, 2560 2562 CEBCA12E1E3A660100C73293 /* OverrideContentSecurityPolicy.mm */, 2563 2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */, 2561 2564 F44C79FB20F9E50C0014478C /* ParserYieldTokenPlugIn.mm */, 2562 2565 F44C79FD20F9E8710014478C /* ParserYieldTokenTests.h */, … … 4422 4425 0E404A8C2166DE0A008271BA /* InjectedBundleNodeHandleIsSelectElement.mm in Sources */, 4423 4426 79C5D431209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm in Sources */, 4427 2D3CA3A8221DF4B40088E803 /* PageOverlayPlugin.mm in Sources */, 4424 4428 F44C7A0020F9EEBF0014478C /* ParserYieldTokenPlugIn.mm in Sources */, 4425 4429 A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r241854 r241899 5137 5137 } 5138 5138 5139 static void traverseLayerTree(CALayer *layer, void(^block)(CALayer *)) 5140 { 5141 for (CALayer *child in layer.sublayers) 5142 traverseLayerTree(child, block); 5143 block(layer); 5144 } 5145 5146 static bool hasOverlay(CALayer *layer) 5147 { 5148 __block bool hasViewOverlay = false; 5149 traverseLayerTree(layer, ^(CALayer *layer) { 5150 if ([layer.name isEqualToString:@"View overlay container"]) 5151 hasViewOverlay = true; 5152 }); 5153 return hasViewOverlay; 5154 } 5155 5156 TEST(ProcessSwap, PageOverlayLayerPersistence) 5157 { 5158 auto processPoolConfiguration = psonProcessPoolConfiguration(); 5159 [processPoolConfiguration setInjectedBundleURL:[[NSBundle mainBundle] URLForResource:@"TestWebKitAPI" withExtension:@"wkbundle"]]; 5160 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 5161 [processPool _setObject:@"PageOverlayPlugIn" forBundleParameter:TestWebKitAPI::Util::TestPlugInClassNameParameter]; 5162 5163 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 5164 [webViewConfiguration setProcessPool:processPool.get()]; 5165 5166 auto handler = adoptNS([[PSONScheme alloc] init]); 5167 [handler addMappingFromURLString:@"pson://www.webkit.org/page-overlay" toData:""]; 5168 [handler addMappingFromURLString:@"pson://www.apple.com/page-overlay" toData:""]; 5169 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 5170 5171 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 5172 5173 auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]); 5174 [webView setNavigationDelegate:navigationDelegate.get()]; 5175 5176 auto request = adoptNS([NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/page-overlay"]]); 5177 [webView loadRequest:request.get()]; 5178 5179 TestWebKitAPI::Util::run(&done); 5180 done = false; 5181 5182 [webView waitForNextPresentationUpdate]; 5183 5184 EXPECT_TRUE(hasOverlay([webView layer])); 5185 5186 request = adoptNS([NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/page-overlay"]]); 5187 [webView loadRequest:request.get()]; 5188 5189 TestWebKitAPI::Util::run(&done); 5190 done = false; 5191 5192 [webView waitForNextPresentationUpdate]; 5193 5194 [webView goBack]; // Back to webkit.org. 5195 5196 [webView waitForNextPresentationUpdate]; 5197 5198 EXPECT_TRUE(hasOverlay([webView layer])); 5199 } 5200 5139 5201 #endif // WK_API_ENABLED
Note: See TracChangeset
for help on using the changeset viewer.