Bug 214988

Summary: Update service worker if certificate info does not match when soft updating
Product: WebKit Reporter: youenn fablet <youennf>
Component: Service WorkersAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, cdumez, Hironori.Fujii, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing none

Description youenn fablet 2020-07-30 13:46:46 PDT
Update service worker if certificate info does not match when soft updating
Comment 1 youenn fablet 2020-07-30 13:48:41 PDT
Created attachment 405611 [details]
Patch
Comment 2 youenn fablet 2020-07-31 02:37:45 PDT
Created attachment 405678 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2020-07-31 03:20:57 PDT
<rdar://problem/66373182>
Comment 4 Alex Christensen 2020-07-31 09:49:01 PDT
Comment on attachment 405678 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405678&action=review

> Tools/TestWebKitAPI/cocoa/HTTPServer.h:49
> +    HTTPServer(std::initializer_list<std::pair<String, HTTPResponse>>, Protocol = Protocol::Http, CertificateVerifier&& = nullptr, RetainPtr<SecIdentityRef>&& = nullptr, const String& port = { });

port should be an Optional<uint16_t> and we should do makeString in HTTPServer instead of String::number in the test.

> Tools/TestWebKitAPI/cocoa/HTTPServer.h:60
> +    static RetainPtr<nw_parameters_t> listenerParameters(Protocol, CertificateVerifier&&, RetainPtr<SecIdentityRef>&& = nullptr, const String& port = { });

Default parameters are probably unnecessary here.

> Tools/TestWebKitAPI/cocoa/HTTPServer.mm:57
> +    if (!customTestIdentity)

We only need this if protocol is not Protocol::Http.
Comment 5 Alex Christensen 2020-07-31 09:49:44 PDT
Comment on attachment 405678 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405678&action=review

> Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:2242
> +    "            while (++counter < 20 && (!registration.installing && !registration.waiting))"
> +    "                await new Promise(resolve => setTimeout(resolve, 50));"

Also, this looks like it may become flaky on slow bots.  Is there a more direct way to do this?
Comment 6 youenn fablet 2020-07-31 10:04:04 PDT
(In reply to Alex Christensen from comment #5)
> Comment on attachment 405678 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=405678&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:2242
> > +    "            while (++counter < 20 && (!registration.installing && !registration.waiting))"
> > +    "                await new Promise(resolve => setTimeout(resolve, 50));"
> 
> Also, this looks like it may become flaky on slow bots.  Is there a more
> direct way to do this?

OK, will use an event + setTimeout in case event is too slow/is not fired
Comment 7 youenn fablet 2020-07-31 10:04:44 PDT
Created attachment 405701 [details]
Patch for landing
Comment 8 EWS 2020-07-31 10:54:52 PDT
Committed r265150: <https://trac.webkit.org/changeset/265150>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 405701 [details].
Comment 9 Fujii Hironori 2020-07-31 11:38:41 PDT
AppleWin port can't compile since this change. EWS reported:

C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\platform\network\cf\CertificateInfo.h(100,38): message : The initializer contains too many elements (compiling source file C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\loader\archive\cf\LegacyWebArchive.cpp) [C:\cygwin\home\buildbot\worker\Windows-EWS\build\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\platform\network\cf\CertificateInfo.h(100,39): error C2065: 'SecTrustRef': undeclared identifier (compiling source file C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\loader\cf\ResourceLoaderCFNet.cpp) [C:\cygwin\home\buildbot\worker\Windows-EWS\build\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\platform\network\cf\CertificateInfo.h(100,52): error C2065: 'SecTrustRef': undeclared identifier (compiling source file C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\loader\cf\ResourceLoaderCFNet.cpp) [C:\cygwin\home\buildbot\worker\Windows-EWS\build\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\platform\network\cf\CertificateInfo.h(100,64): error C2440: 'initializing': cannot convert from 'initializer list' to 'bool' (compiling source file C:\cygwin\home\buildbot\worker\Windows-EWS\build\Source\WebCore\loader\cf\ResourceLoaderCFNet.cpp) [C:\cygwin\home\buildbot\worker\Windows-EWS\build\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
Comment 10 Alex Christensen 2020-07-31 12:39:36 PDT
http://trac.webkit.org/r265155
Comment 11 youenn fablet 2020-07-31 12:50:19 PDT
Thanks!