Bug 227524

Summary: ServiceWorkerRegistration.unregister method fails in WKWebView
Product: WebKit Reporter: Kiran S <18kirans>
Component: Service WorkersAssignee: Kate Cheney <katherine_cheney>
Status: RESOLVED FIXED    
Severity: Normal CC: ayumi_kojima, cdumez, deepa.gopikuttan.pillai, joji.jacob, katherine_cheney, kiran.satheesan, mehmetgelisin, prabakar.paulsami, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: iPhone / iPad   
OS: iOS 14   
Attachments:
Description Flags
Trying to invoke unregister from dev console
none
Patch none

Description Kiran S 2021-06-30 05:34:05 PDT
Created attachment 432585 [details]
Trying to invoke unregister from dev console

Overview

    ServiceWorkerRegistration.unregister method fails in WKWebView. Error message "TypeError: Job rejected for non app-bound domain" is displayed in console.
    The current domain is listed as a App Bound Domain and service worker registration is also successful. But the issue is with unregister method.
    
    I have also attached a video of the error. In the video I have tried to invoke unregister method from Dev Console.

Steps to Reproduce
    
    1. For an App Bound Domain. Register a service worker
    2. After the service worker is activated try to unregister it
    3. Sample Code
        navigator.serviceWorker.getRegistration()
            .then(registration => registration.unregister())
            .then(() => console.log('Unregistration success'))
            .catch(error => console.error('Unregistration failed', error));

Actual Result

    unregister method fails with the error - "TypeError: Job rejected for non app-bound domain".

Expected Result

    Service worker registration gets unregistered

Environment

    Device: iPad Mini 4
    OS: iOS 14.7 (18G5042c)
Comment 1 Chris Dumez 2021-07-01 18:40:06 PDT
App bound domains -> Kate :)
Comment 2 Radar WebKit Bug Importer 2021-07-07 05:35:26 PDT
<rdar://problem/80264108>
Comment 3 Kate Cheney 2021-07-25 09:13:09 PDT
Created attachment 434180 [details]
Patch
Comment 4 EWS 2021-07-26 15:09:35 PDT
Committed r280319 (239967@main): <https://commits.webkit.org/239967@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 434180 [details].
Comment 5 Kiran Satheesan 2021-07-28 03:14:00 PDT
Hi

Thanks the fix.

Could you please provide the following info as well

  - In which iOS version will this changes be released ?
  - Is it possible to upgrade the webview locally for trying out the new fix ?
Comment 6 Kate Cheney 2021-08-05 10:57:32 PDT
(In reply to Kiran Satheesan from comment #5)
> Hi
> 
> Thanks the fix.
> 
> Could you please provide the following info as well
> 
>   - In which iOS version will this changes be released ?
>   - Is it possible to upgrade the webview locally for trying out the new fix
> ?

Bugzilla tracks the WebKit Open Source Project which is not in charge of future iOS releases, so I have no comment there.
Comment 7 Kate Cheney 2021-09-03 14:47:39 PDT
This should be in the latest iOS 15 beta, so you can test it there.
Comment 9 Kate Cheney 2021-10-27 13:03:54 PDT
*** Bug 227918 has been marked as a duplicate of this bug. ***