Changeset 288201 in webkit
- Timestamp:
- Jan 19, 2022 9:12:35 AM (6 months ago)
- Location:
- trunk
- Files:
-
- 36 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get-resultingClientId.https-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/historical.https.any.serviceworker-expected.txt (modified) (1 diff)
-
Source/WTF/wtf/UUID.h (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/DOMImplementation.cpp (modified) (5 diffs)
-
Source/WebCore/dom/DOMImplementation.h (modified) (2 diffs)
-
Source/WebCore/dom/Document.cpp (modified) (2 diffs)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
-
Source/WebCore/dom/ScriptExecutionContext.cpp (modified) (1 diff)
-
Source/WebCore/dom/ScriptExecutionContext.h (modified) (1 diff)
-
Source/WebCore/html/FTPDirectoryDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLDocument.h (modified) (3 diffs)
-
Source/WebCore/html/ImageDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/MediaDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/ModelDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/PluginDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/TextDocument.cpp (modified) (1 diff)
-
Source/WebCore/html/TextDocument.h (modified) (1 diff)
-
Source/WebCore/inspector/DOMPatchSupport.cpp (modified) (1 diff)
-
Source/WebCore/loader/DocumentLoader.cpp (modified) (11 diffs)
-
Source/WebCore/loader/DocumentLoader.h (modified) (4 diffs)
-
Source/WebCore/loader/DocumentWriter.cpp (modified) (3 diffs)
-
Source/WebCore/loader/DocumentWriter.h (modified) (3 diffs)
-
Source/WebCore/loader/SinkDocument.cpp (modified) (1 diff)
-
Source/WebCore/platform/ScriptExecutionContextIdentifier.h (modified) (1 diff)
-
Source/WebCore/workers/service/FetchEvent.cpp (modified) (1 diff)
-
Source/WebCore/workers/service/FetchEvent.h (modified) (3 diffs)
-
Source/WebCore/workers/service/FetchEvent.idl (modified) (2 diffs)
-
Source/WebCore/workers/service/server/SWServer.cpp (modified) (1 diff)
-
Source/WebCore/xml/XMLHttpRequest.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r288197 r288201 1 2022-01-19 Youenn Fablet <youenn@apple.com> 2 3 Improve computation of service worker FetchEvent.resultingClientId 4 https://bugs.webkit.org/show_bug.cgi?id=235107 5 6 Reviewed by Darin Adler. 7 8 * web-platform-tests/service-workers/service-worker/clients-get-resultingClientId.https-expected.txt: 9 * web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt: 10 * web-platform-tests/service-workers/service-worker/historical.https.any.serviceworker-expected.txt: 11 1 12 2022-01-19 Alexey Shvayka <ashvayka@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get-resultingClientId.https-expected.txt
r267647 r288201 1 1 2 2 PASS global setup 3 FAIL get(resultingClientId) for same-origin document assert_equals: promiseValue expected "client" but got "undefinedValue" 3 PASS get(resultingClientId) for same-origin document 4 4 PASS get(resultingClientId) on cross-origin redirect 5 PASS get(resultingClientId) for document sandboxed by CSP header 6 FAIL get(resultingClientId) for document sandboxed by CSP header with allow-same-origin assert_equals: promiseValue expected "client" but got "undefinedValue" 5 FAIL get(resultingClientId) for document sandboxed by CSP header assert_equals: promiseValue expected "undefinedValue" but got "client" 6 PASS get(resultingClientId) for document sandboxed by CSP header with allow-same-origin 7 7 PASS global cleanup 8 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt
r267647 r288201 1 1 2 2 FAIL Test Clients.get() assert_array_equals: expected property 1 to be false but got true (expected array ["visible", false, "https://localhost:9443/service-workers/service-worker/resources/clients-get-frame.html#2", "window", "nested"] got ["visible", true, "https://localhost:9443/service-workers/service-worker/resources/clients-get-frame.html#2", "window", "nested"]) 3 FAIL Test successful Clients.get(FetchEvent.resultingClientId) assert_false: Clients.get(FetchEvent.resultingClientId) resolved with a Client expected false got true 3 PASS Test successful Clients.get(FetchEvent.resultingClientId) 4 4 PASS Test unsuccessful Clients.get(FetchEvent.resultingClientId) 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/historical.https.any.serviceworker-expected.txt
r279389 r288201 1 1 2 FAIL targetClientId should not be on FetchEvent assert_false: expected false got true 2 PASS targetClientId should not be on FetchEvent 3 3 -
trunk/Source/WTF/wtf/UUID.h
r288119 r288201 86 86 WTF_EXPORT_PRIVATE String toString() const; 87 87 88 operator bool() const { return !!m_data; } 89 88 90 private: 89 91 WTF_EXPORT_PRIVATE UUID(); -
trunk/Source/WebCore/ChangeLog
r288200 r288201 1 2022-01-19 Youenn Fablet <youenn@apple.com> 2 3 Improve computation of service worker FetchEvent.resultingClientId 4 https://bugs.webkit.org/show_bug.cgi?id=235107 5 6 Reviewed by Darin Adler. 7 8 We are now passing the reserved client ID generated by DocumentLoader to the generated document. 9 Previously, we would register a temporary ID that we would drop later on when creating a new document. 10 This allows to be closer to spec, though we need to handle the case of a document whose origin gets unique 11 due to CSP or sandboxing making a document origin unique. 12 We are also removing targetClientId, which was renamed in the spec to replacesClientId but is also not implemented in any browser yet. 13 14 Covered by existing tests. 15 16 * dom/DOMImplementation.cpp: 17 * dom/DOMImplementation.h: 18 * dom/Document.cpp: 19 * dom/Document.h: 20 * dom/ScriptExecutionContext.cpp: 21 * dom/ScriptExecutionContext.h: 22 * html/FTPDirectoryDocument.cpp: 23 * html/HTMLDocument.cpp: 24 * html/HTMLDocument.h: 25 * html/ImageDocument.cpp: 26 * html/MediaDocument.cpp: 27 * html/ModelDocument.cpp: 28 * html/PluginDocument.cpp: 29 * html/TextDocument.cpp: 30 * html/TextDocument.h: 31 * inspector/DOMPatchSupport.cpp: 32 * loader/DocumentLoader.cpp: 33 * loader/DocumentLoader.h: 34 * loader/DocumentWriter.cpp: 35 * loader/DocumentWriter.h: 36 * loader/SinkDocument.cpp: 37 * workers/service/FetchEvent.cpp: 38 * workers/service/FetchEvent.h: 39 * workers/service/FetchEvent.idl: 40 * workers/service/server/SWServer.cpp: 41 * xml/XMLHttpRequest.cpp: 42 1 43 2022-01-19 Michael Catanzaro <mcatanzaro@gnome.org> 2 44 -
trunk/Source/WebCore/dom/DOMImplementation.cpp
r285936 r288201 125 125 Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title) 126 126 { 127 auto document = HTMLDocument::create(nullptr, m_document.settings(), URL() );127 auto document = HTMLDocument::create(nullptr, m_document.settings(), URL(), { }); 128 128 document->open(); 129 129 document->write(nullptr, { "<!doctype html><html><head></head><body></body></html>"_s }); … … 139 139 } 140 140 141 Ref<Document> DOMImplementation::createDocument(const String& contentType, Frame* frame, const Settings& settings, const URL& url )141 Ref<Document> DOMImplementation::createDocument(const String& contentType, Frame* frame, const Settings& settings, const URL& url, ScriptExecutionContextIdentifier documentIdentifier) 142 142 { 143 143 // FIXME: Inelegant to have this here just because this is the home of DOM APIs for creating documents. … … 147 147 // Plug-ins cannot take over for HTML, XHTML, plain text, or non-PDF images. 148 148 if (equalLettersIgnoringASCIICase(contentType, "text/html")) 149 return HTMLDocument::create(frame, settings, url );149 return HTMLDocument::create(frame, settings, url, documentIdentifier); 150 150 if (equalLettersIgnoringASCIICase(contentType, "application/xhtml+xml")) 151 151 return XMLDocument::createXHTML(frame, settings, url); 152 152 if (equalLettersIgnoringASCIICase(contentType, "text/plain")) 153 return TextDocument::create(frame, settings, url );153 return TextDocument::create(frame, settings, url, documentIdentifier); 154 154 bool isImage = MIMETypeRegistry::isSupportedImageMIMEType(contentType); 155 155 if (frame && isImage && !MIMETypeRegistry::isPDFOrPostScriptMIMEType(contentType)) … … 194 194 return ImageDocument::create(*frame, url); 195 195 if (MIMETypeRegistry::isTextMIMEType(contentType)) 196 return TextDocument::create(frame, settings, url );196 return TextDocument::create(frame, settings, url, documentIdentifier); 197 197 if (equalLettersIgnoringASCIICase(contentType, "image/svg+xml")) 198 198 return SVGDocument::create(frame, settings, url); … … 202 202 return document; 203 203 } 204 return HTMLDocument::create(frame, settings, url); 205 } 206 207 } 204 205 return HTMLDocument::create(frame, settings, url, documentIdentifier); 206 } 207 208 } -
trunk/Source/WebCore/dom/DOMImplementation.h
r268114 r288201 25 25 26 26 #include "ExceptionOr.h" 27 #include "ScriptExecutionContextIdentifier.h" 27 28 #include "XMLDocument.h" 28 29 … … 44 45 WEBCORE_EXPORT static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media); 45 46 46 static Ref<Document> createDocument(const String& contentType, Frame*, const Settings&, const URL& );47 static Ref<Document> createDocument(const String& contentType, Frame*, const Settings&, const URL&, ScriptExecutionContextIdentifier = { }); 47 48 48 49 private: -
trunk/Source/WebCore/dom/Document.cpp
r288162 r288201 606 606 } 607 607 608 Document::Document(Frame* frame, const Settings& settings, const URL& url, DocumentClasses documentClasses, unsigned constructionFlags )608 Document::Document(Frame* frame, const Settings& settings, const URL& url, DocumentClasses documentClasses, unsigned constructionFlags, ScriptExecutionContextIdentifier identifier) 609 609 : ContainerNode(*this, CreateDocument) 610 610 , TreeScope(*this) 611 , ScriptExecutionContext(identifier) 611 612 , FrameDestructionObserver(frame) 612 613 , m_settings(settings) … … 7513 7514 7514 7515 if (isHTMLDocument()) 7515 m_templateDocument = HTMLDocument::create(nullptr, m_settings, aboutBlankURL() );7516 m_templateDocument = HTMLDocument::create(nullptr, m_settings, aboutBlankURL(), { }); 7516 7517 else 7517 7518 m_templateDocument = create(m_settings, aboutBlankURL()); -
trunk/Source/WebCore/dom/Document.h
r288087 r288201 1677 1677 protected: 1678 1678 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 }; 1679 WEBCORE_EXPORT Document(Frame*, const Settings&, const URL&, DocumentClasses = { }, unsigned constructionFlags = 0 );1679 WEBCORE_EXPORT Document(Frame*, const Settings&, const URL&, DocumentClasses = { }, unsigned constructionFlags = 0, ScriptExecutionContextIdentifier = { }); 1680 1680 1681 1681 void clearXMLVersion() { m_xmlVersion = String(); } -
trunk/Source/WebCore/dom/ScriptExecutionContext.cpp
r288093 r288201 112 112 }; 113 113 114 ScriptExecutionContext::ScriptExecutionContext( )115 : m_identifier( ScriptExecutionContextIdentifier::generate())114 ScriptExecutionContext::ScriptExecutionContext(ScriptExecutionContextIdentifier contextIdentifier) 115 : m_identifier(contextIdentifier ? contextIdentifier : ScriptExecutionContextIdentifier::generate()) 116 116 { 117 117 Locker locker { allScriptExecutionContextsMapLock }; 118 ASSERT(!allScriptExecutionContextsMap().contains(m_identifier)); 118 119 allScriptExecutionContextsMap().add(m_identifier, this); 119 120 } -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r286625 r288201 90 90 class ScriptExecutionContext : public SecurityContext, public CanMakeWeakPtr<ScriptExecutionContext> { 91 91 public: 92 ScriptExecutionContext();92 explicit ScriptExecutionContext(ScriptExecutionContextIdentifier = { }); 93 93 virtual ~ScriptExecutionContext(); 94 94 -
trunk/Source/WebCore/html/FTPDirectoryDocument.cpp
r287021 r288201 419 419 420 420 FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const Settings& settings, const URL& url) 421 : HTMLDocument(frame, settings, url )421 : HTMLDocument(frame, settings, url, { }) 422 422 { 423 423 #if !LOG_DISABLED -
trunk/Source/WebCore/html/HTMLDocument.cpp
r287232 r288201 90 90 Ref<HTMLDocument> HTMLDocument::createSynthesizedDocument(Frame& frame, const URL& url) 91 91 { 92 return adoptRef(*new HTMLDocument(&frame, frame.settings(), url, { DocumentClass::HTML }, Synthesized));93 } 94 95 HTMLDocument::HTMLDocument(Frame* frame, const Settings& settings, const URL& url, DocumentClasses documentClasses, unsigned constructionFlags)96 : Document(frame, settings, url, documentClasses | DocumentClasses(DocumentClass::HTML), constructionFlags )92 return adoptRef(*new HTMLDocument(&frame, frame.settings(), url, { }, { DocumentClass::HTML }, Synthesized)); 93 } 94 95 HTMLDocument::HTMLDocument(Frame* frame, const Settings& settings, const URL& url, ScriptExecutionContextIdentifier documentIdentifier, DocumentClasses documentClasses, unsigned constructionFlags) 96 : Document(frame, settings, url, documentClasses | DocumentClasses(DocumentClass::HTML), constructionFlags, documentIdentifier) 97 97 { 98 98 clearXMLVersion(); -
trunk/Source/WebCore/html/HTMLDocument.h
r286151 r288201 30 30 WTF_MAKE_ISO_ALLOCATED(HTMLDocument); 31 31 public: 32 static Ref<HTMLDocument> create(Frame*, const Settings&, const URL& );32 static Ref<HTMLDocument> create(Frame*, const Settings&, const URL&, ScriptExecutionContextIdentifier = { }); 33 33 static Ref<HTMLDocument> createSynthesizedDocument(Frame&, const URL&); 34 34 virtual ~HTMLDocument(); … … 55 55 56 56 protected: 57 HTMLDocument(Frame*, const Settings&, const URL&, DocumentClasses = { }, unsigned constructionFlags = 0);57 HTMLDocument(Frame*, const Settings&, const URL&, ScriptExecutionContextIdentifier, DocumentClasses = { }, unsigned constructionFlags = 0); 58 58 59 59 private: … … 66 66 }; 67 67 68 inline Ref<HTMLDocument> HTMLDocument::create(Frame* frame, const Settings& settings, const URL& url )68 inline Ref<HTMLDocument> HTMLDocument::create(Frame* frame, const Settings& settings, const URL& url, ScriptExecutionContextIdentifier identifier) 69 69 { 70 return adoptRef(*new HTMLDocument(frame, settings, url, { DocumentClass::HTML }));70 return adoptRef(*new HTMLDocument(frame, settings, url, identifier, { DocumentClass::HTML }, 0)); 71 71 } 72 72 -
trunk/Source/WebCore/html/ImageDocument.cpp
r287021 r288201 199 199 200 200 ImageDocument::ImageDocument(Frame& frame, const URL& url) 201 : HTMLDocument(&frame, frame.settings(), url, { DocumentClass::Image })201 : HTMLDocument(&frame, frame.settings(), url, { }, { DocumentClass::Image }) 202 202 , m_imageElement(nullptr) 203 203 , m_imageSizeIsKnown(false) -
trunk/Source/WebCore/html/MediaDocument.cpp
r286151 r288201 141 141 142 142 MediaDocument::MediaDocument(Frame* frame, const Settings& settings, const URL& url) 143 : HTMLDocument(frame, settings, url, { DocumentClass::Media })143 : HTMLDocument(frame, settings, url, { }, { DocumentClass::Media }) 144 144 { 145 145 setCompatibilityMode(DocumentCompatibilityMode::QuirksMode); -
trunk/Source/WebCore/html/ModelDocument.cpp
r286151 r288201 139 139 140 140 ModelDocument::ModelDocument(Frame* frame, const Settings& settings, const URL& url) 141 : HTMLDocument(frame, settings, url, { DocumentClass::Model })141 : HTMLDocument(frame, settings, url, { }, { DocumentClass::Model }) 142 142 { 143 143 if (frame) -
trunk/Source/WebCore/html/PluginDocument.cpp
r286151 r288201 145 145 146 146 PluginDocument::PluginDocument(Frame& frame, const URL& url) 147 : HTMLDocument(&frame, frame.settings(), url, { DocumentClass::Plugin })147 : HTMLDocument(&frame, frame.settings(), url, { }, { DocumentClass::Plugin }) 148 148 { 149 149 setCompatibilityMode(DocumentCompatibilityMode::QuirksMode); -
trunk/Source/WebCore/html/TextDocument.cpp
r286151 r288201 33 33 WTF_MAKE_ISO_ALLOCATED_IMPL(TextDocument); 34 34 35 TextDocument::TextDocument(Frame* frame, const Settings& settings, const URL& url )36 : HTMLDocument(frame, settings, url, { DocumentClass::Text })35 TextDocument::TextDocument(Frame* frame, const Settings& settings, const URL& url, ScriptExecutionContextIdentifier identifier) 36 : HTMLDocument(frame, settings, url, identifier, { DocumentClass::Text }) 37 37 { 38 38 setCompatibilityMode(DocumentCompatibilityMode::QuirksMode); -
trunk/Source/WebCore/html/TextDocument.h
r268114 r288201 32 32 WTF_MAKE_ISO_ALLOCATED(TextDocument); 33 33 public: 34 static Ref<TextDocument> create(Frame* frame, const Settings& settings, const URL& url )34 static Ref<TextDocument> create(Frame* frame, const Settings& settings, const URL& url, ScriptExecutionContextIdentifier identifier) 35 35 { 36 return adoptRef(*new TextDocument(frame, settings, url ));36 return adoptRef(*new TextDocument(frame, settings, url, identifier)); 37 37 } 38 38 39 39 private: 40 TextDocument(Frame*, const Settings&, const URL& );40 TextDocument(Frame*, const Settings&, const URL&, ScriptExecutionContextIdentifier); 41 41 42 42 Ref<DocumentParser> createParser() override; -
trunk/Source/WebCore/inspector/DOMPatchSupport.cpp
r285195 r288201 78 78 RefPtr<Document> newDocument; 79 79 if (m_document.isHTMLDocument()) 80 newDocument = HTMLDocument::create(nullptr, m_document.settings(), URL() );80 newDocument = HTMLDocument::create(nullptr, m_document.settings(), URL(), { }); 81 81 else if (m_document.isXHTMLDocument()) 82 82 newDocument = XMLDocument::createXHTML(nullptr, m_document.settings(), URL()); -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r288093 r288201 151 151 } 152 152 153 static HashMap<ScriptExecutionContextIdentifier, DocumentLoader*>& temporaryIdentifierToLoaderMap()153 static HashMap<ScriptExecutionContextIdentifier, DocumentLoader*>& scriptExecutionContextIdentifierToLoaderMap() 154 154 { 155 155 static NeverDestroyed<HashMap<ScriptExecutionContextIdentifier, DocumentLoader*>> map; … … 157 157 } 158 158 159 DocumentLoader* DocumentLoader::from TemporaryDocumentIdentifier(ScriptExecutionContextIdentifier identifier)160 { 161 return temporaryIdentifierToLoaderMap().get(identifier);159 DocumentLoader* DocumentLoader::fromScriptExecutionContextIdentifier(ScriptExecutionContextIdentifier identifier) 160 { 161 return scriptExecutionContextIdentifierToLoaderMap().get(identifier); 162 162 } 163 163 … … 201 201 202 202 #if ENABLE(SERVICE_WORKER) 203 if (m_ temporaryServiceWorkerClient) {204 ASSERT( temporaryIdentifierToLoaderMap().contains(*m_temporaryServiceWorkerClient));205 temporaryIdentifierToLoaderMap().remove(*m_temporaryServiceWorkerClient);203 if (m_resultingClientId) { 204 ASSERT(scriptExecutionContextIdentifierToLoaderMap().contains(m_resultingClientId)); 205 scriptExecutionContextIdentifierToLoaderMap().remove(m_resultingClientId); 206 206 } 207 207 #endif … … 556 556 } 557 557 558 ScriptExecutionContextIdentifier DocumentLoader::resultingClientId() const 559 { 560 return m_resultingClientId; 561 } 562 558 563 void DocumentLoader::matchRegistration(const URL& url, SWClientConnection::RegistrationCallback&& callback) 559 564 { … … 590 595 if (m_serviceWorkerRegistrationData) { 591 596 m_serviceWorkerRegistrationData = { }; 592 unregisterTemporaryServiceWorkerClient(); 593 } 597 unregisterReservedServiceWorkerClient(); 598 } 599 594 600 willSendRequest(WTFMove(request), redirectResponse, [completionHandler = WTFMove(completionHandler), protectedThis = Ref { *this }, this] (auto&& request) mutable { 595 601 ASSERT(!m_substituteData.isValid()); … … 1203 1209 if (!m_gotFirstByte) { 1204 1210 m_gotFirstByte = true; 1205 bool hasBegun = m_writer.begin(documentURL(), false );1211 bool hasBegun = m_writer.begin(documentURL(), false, nullptr, m_resultingClientId); 1206 1212 if (!hasBegun) 1207 1213 return; … … 1231 1237 #if ENABLE(SERVICE_WORKER) 1232 1238 if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) { 1233 if (m_serviceWorkerRegistrationData && m_serviceWorkerRegistrationData->activeWorker) { 1234 document.setActiveServiceWorker(ServiceWorker::getOrCreate(document, WTFMove(m_serviceWorkerRegistrationData->activeWorker.value()))); 1235 m_serviceWorkerRegistrationData = { }; 1236 } else if (auto* parent = document.parentDocument()) { 1237 if (shouldUseActiveServiceWorkerFromParent(document, *parent)) 1238 document.setActiveServiceWorker(parent->activeServiceWorker()); 1239 if (!document.securityOrigin().isUnique()) { 1240 if (m_serviceWorkerRegistrationData && m_serviceWorkerRegistrationData->activeWorker) { 1241 document.setActiveServiceWorker(ServiceWorker::getOrCreate(document, WTFMove(m_serviceWorkerRegistrationData->activeWorker.value()))); 1242 m_serviceWorkerRegistrationData = { }; 1243 } else if (auto* parent = document.parentDocument()) { 1244 if (shouldUseActiveServiceWorkerFromParent(document, *parent)) 1245 document.setActiveServiceWorker(parent->activeServiceWorker()); 1246 } 1239 1247 } 1240 1248 … … 1242 1250 document.setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection()); 1243 1251 1244 // We currently unregister the temporary service worker client since we now registered the real document. 1245 // FIXME: We should make the real document use the temporary client identifier. 1246 unregisterTemporaryServiceWorkerClient(); 1252 if (m_resultingClientId) { 1253 if (m_resultingClientId != document.identifier()) 1254 unregisterReservedServiceWorkerClient(); 1255 scriptExecutionContextIdentifierToLoaderMap().remove(m_resultingClientId); 1256 m_resultingClientId = { }; 1257 } 1247 1258 } 1248 1259 #endif … … 2067 2078 } 2068 2079 2069 void DocumentLoader::unregister TemporaryServiceWorkerClient()2080 void DocumentLoader::unregisterReservedServiceWorkerClient() 2070 2081 { 2071 2082 #if ENABLE(SERVICE_WORKER) 2072 if (!m_ temporaryServiceWorkerClient|| !RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled())2083 if (!m_resultingClientId || !RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) 2073 2084 return; 2074 2085 2075 2086 auto& serviceWorkerConnection = ServiceWorkerProvider::singleton().serviceWorkerConnection(); 2076 serviceWorkerConnection.unregisterServiceWorkerClient( *m_temporaryServiceWorkerClient);2087 serviceWorkerConnection.unregisterServiceWorkerClient(m_resultingClientId); 2077 2088 #endif 2078 2089 } … … 2093 2104 DefersLoadingPolicy::AllowDefersLoading, 2094 2105 CachingPolicy::AllowCaching); 2106 2095 2107 #if ENABLE(SERVICE_WORKER) 2096 if (!m_temporaryServiceWorkerClient) {2097 // The main navigation load will trigger the registration of the temp client.2098 m_temporaryServiceWorkerClient = ScriptExecutionContextIdentifier::generate();2099 ASSERT(!temporaryIdentifierToLoaderMap().contains(*m_temporaryServiceWorkerClient));2100 temporaryIdentifierToLoaderMap().add(*m_temporaryServiceWorkerClient, this);2101 }2102 mainResourceLoadOptions.clientIdentifier = m_temporaryServiceWorkerClient; 2103 #endif 2108 // The main navigation load will trigger the registration of the client. 2109 if (m_resultingClientId) 2110 scriptExecutionContextIdentifierToLoaderMap().remove(m_resultingClientId); 2111 m_resultingClientId = ScriptExecutionContextIdentifier::generate(); 2112 ASSERT(!scriptExecutionContextIdentifierToLoaderMap().contains(m_resultingClientId)); 2113 scriptExecutionContextIdentifierToLoaderMap().add(m_resultingClientId, this); 2114 #endif 2115 2104 2116 CachedResourceRequest mainResourceRequest(WTFMove(request), mainResourceLoadOptions); 2105 2117 if (!m_frame->isMainFrame() && m_frame->document()) { … … 2213 2225 m_isContinuingLoadAfterProvisionalLoadStarted = false; 2214 2226 2215 unregister TemporaryServiceWorkerClient();2227 unregisterReservedServiceWorkerClient(); 2216 2228 } 2217 2229 -
trunk/Source/WebCore/loader/DocumentLoader.h
r287684 r288201 172 172 } 173 173 174 WEBCORE_EXPORT static DocumentLoader* from TemporaryDocumentIdentifier(ScriptExecutionContextIdentifier);174 WEBCORE_EXPORT static DocumentLoader* fromScriptExecutionContextIdentifier(ScriptExecutionContextIdentifier); 175 175 176 176 WEBCORE_EXPORT virtual ~DocumentLoader(); … … 440 440 #if ENABLE(SERVICE_WORKER) 441 441 WEBCORE_EXPORT bool setControllingServiceWorkerRegistration(ServiceWorkerRegistrationData&&); 442 WEBCORE_EXPORT ScriptExecutionContextIdentifier resultingClientId() const; 442 443 #endif 443 444 … … 469 470 void matchRegistration(const URL&, CompletionHandler<void(std::optional<ServiceWorkerRegistrationData>&&)>&&); 470 471 #endif 471 void unregister TemporaryServiceWorkerClient();472 void unregisterReservedServiceWorkerClient(); 472 473 473 474 std::optional<CrossOriginOpenerPolicyEnforcementResult> doCrossOriginOpenerHandlingOfResponse(const ResourceResponse&); … … 689 690 #if ENABLE(SERVICE_WORKER) 690 691 std::optional<ServiceWorkerRegistrationData> m_serviceWorkerRegistrationData; 691 std::optional<ScriptExecutionContextIdentifier> m_temporaryServiceWorkerClient; 692 #endif 692 #endif 693 ScriptExecutionContextIdentifier m_resultingClientId; 693 694 694 695 #if ASSERT_ENABLED -
trunk/Source/WebCore/loader/DocumentWriter.cpp
r287684 r288201 113 113 } 114 114 115 Ref<Document> DocumentWriter::createDocument(const URL& url )115 Ref<Document> DocumentWriter::createDocument(const URL& url, ScriptExecutionContextIdentifier documentIdentifier) 116 116 { 117 117 if (!m_frame->loader().stateMachine().isDisplayingInitialEmptyDocument() && m_frame->loader().client().shouldAlwaysUsePluginDocument(m_mimeType)) … … 123 123 if (!m_frame->loader().client().hasHTMLView()) 124 124 return Document::createNonRenderedPlaceholder(*m_frame, url); 125 return DOMImplementation::createDocument(m_mimeType, m_frame.get(), m_frame->settings(), url );126 } 127 128 bool DocumentWriter::begin(const URL& urlReference, bool dispatch, Document* ownerDocument )125 return DOMImplementation::createDocument(m_mimeType, m_frame.get(), m_frame->settings(), url, documentIdentifier); 126 } 127 128 bool DocumentWriter::begin(const URL& urlReference, bool dispatch, Document* ownerDocument, ScriptExecutionContextIdentifier documentIdentifier) 129 129 { 130 130 // We grab a local copy of the URL because it's easy for callers to supply … … 135 135 // Create a new document before clearing the frame, because it may need to 136 136 // inherit an aliased security context. 137 Ref<Document> document = createDocument(url );137 Ref<Document> document = createDocument(url, documentIdentifier); 138 138 139 139 // If the new document is for a Plugin but we're supposed to be sandboxed from Plugins, -
trunk/Source/WebCore/loader/DocumentWriter.h
r287684 r288201 29 29 #pragma once 30 30 31 #include "ScriptExecutionContextIdentifier.h" 31 32 #include <wtf/WeakPtr.h> 32 33 #include <wtf/text/WTFString.h> … … 48 49 49 50 bool begin(); 50 bool begin(const URL&, bool dispatchWindowObjectAvailable = true, Document* ownerDocument = nullptr );51 bool begin(const URL&, bool dispatchWindowObjectAvailable = true, Document* ownerDocument = nullptr, ScriptExecutionContextIdentifier = { }); 51 52 void addData(const SharedBuffer&); 52 53 void insertDataSynchronously(const String&); // For an internal use only to prevent the parser from yielding. … … 68 69 69 70 private: 70 Ref<Document> createDocument(const URL& );71 Ref<Document> createDocument(const URL&, ScriptExecutionContextIdentifier); 71 72 void clear(); 72 73 -
trunk/Source/WebCore/loader/SinkDocument.cpp
r278532 r288201 55 55 56 56 SinkDocument::SinkDocument(Frame& frame, const URL& url) 57 : HTMLDocument(&frame, frame.settings(), url )57 : HTMLDocument(&frame, frame.settings(), url, { }) 58 58 { 59 59 setCompatibilityMode(DocumentCompatibilityMode::QuirksMode); -
trunk/Source/WebCore/platform/ScriptExecutionContextIdentifier.h
r288116 r288201 54 54 } 55 55 56 operator bool() const { return !!m_ processIdentifier; }56 operator bool() const { return !!m_object; } 57 57 58 58 const UUID& object() const { return m_object; } -
trunk/Source/WebCore/workers/service/FetchEvent.cpp
r288093 r288201 63 63 , m_clientId(WTFMove(initializer.clientId)) 64 64 , m_resultingClientId(WTFMove(initializer.resultingClientId)) 65 , m_targetClientId(WTFMove(initializer.targetClientId))66 65 , m_handled(retrieveHandledPromise(globalObject, WTFMove(initializer.handled))) 67 66 { -
trunk/Source/WebCore/workers/service/FetchEvent.h
r288093 r288201 51 51 String clientId; 52 52 String resultingClientId; 53 String targetClientId;54 53 RefPtr<DOMPromise> handled; 55 54 }; … … 73 72 const String& clientId() const { return m_clientId; } 74 73 const String& resultingClientId() const { return m_resultingClientId; } 75 const String& targetClientId() const { return m_targetClientId; }76 74 DOMPromise& handled() const { return m_handled.get(); } 77 75 … … 95 93 String m_clientId; 96 94 String m_resultingClientId; 97 String m_targetClientId;98 95 99 96 bool m_respondWithEntered { false }; -
trunk/Source/WebCore/workers/service/FetchEvent.idl
r288093 r288201 37 37 readonly attribute DOMString clientId; 38 38 readonly attribute DOMString resultingClientId; 39 readonly attribute DOMString targetClientId;40 39 readonly attribute Promise<undefined> handled; 41 40 … … 47 46 DOMString clientId = ""; 48 47 DOMString resultingClientId = ""; 49 DOMString targetClientId = "";50 48 Promise<undefined> handled; 51 49 }; -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r288093 r288201 943 943 } 944 944 945 m_visibleClientIdToInternalClientIdMap.add(data.identifier.object().toString(), clientIdentifier); 945 auto addResult = m_visibleClientIdToInternalClientIdMap.add(data.identifier.object().toString(), clientIdentifier); 946 if (!addResult.isNewEntry) { 947 ASSERT(m_visibleClientIdToInternalClientIdMap.get(data.identifier.object().toString()) == clientIdentifier); 948 ASSERT(m_clientsById.contains(clientIdentifier)); 949 m_clientsById.set(clientIdentifier, WTFMove(data)); 950 return; 951 } 946 952 947 953 ASSERT(!m_clientsById.contains(clientIdentifier)); -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r288088 r288201 182 182 } else { 183 183 if (isHTML) 184 m_responseDocument = HTMLDocument::create(nullptr, context.settings(), m_response.url() );184 m_responseDocument = HTMLDocument::create(nullptr, context.settings(), m_response.url(), { }); 185 185 else 186 186 m_responseDocument = XMLDocument::create(nullptr, context.settings(), m_response.url()); -
trunk/Source/WebKit/ChangeLog
r288185 r288201 1 2022-01-19 Youenn Fablet <youenn@apple.com> 2 3 Improve computation of service worker FetchEvent.resultingClientId 4 https://bugs.webkit.org/show_bug.cgi?id=235107 5 6 Reviewed by Darin Adler. 7 8 * WebProcess/Network/WebLoaderStrategy.cpp: 9 * WebProcess/Storage/WebSWClientConnection.cpp: 10 1 11 2022-01-19 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
r287731 r288201 442 442 frameAncestorOrigins.append(&frame->document()->securityOrigin()); 443 443 loadParameters.frameAncestorOrigins = WTFMove(frameAncestorOrigins); 444 445 #if ENABLE(SERVICE_WORKER) 446 if (auto* documentLoader = resourceLoader.documentLoader()) { 447 if (auto resultingClientId = static_cast<WebDocumentLoader&>(*documentLoader).resultingClientId()) 448 loadParameters.options.clientIdentifier = resultingClientId; 449 } 450 #endif 444 451 } 445 452 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r286419 r288201 179 179 void WebSWClientConnection::setDocumentIsControlled(ScriptExecutionContextIdentifier documentIdentifier, ServiceWorkerRegistrationData&& data, CompletionHandler<void(bool)>&& completionHandler) 180 180 { 181 auto* documentLoader = DocumentLoader::from TemporaryDocumentIdentifier(documentIdentifier);181 auto* documentLoader = DocumentLoader::fromScriptExecutionContextIdentifier(documentIdentifier); 182 182 bool result = documentLoader ? documentLoader->setControllingServiceWorkerRegistration(WTFMove(data)) : false; 183 183 completionHandler(result);
Note: See TracChangeset
for help on using the changeset viewer.