Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56169

Can't register service worker using file:// protocol

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 5.7.0
    • WebEngine
    • None

    Description

      While trying to register service worker from file:// protocol, I am getting the following error:

      Failed to register a ServiceWorker: The URL protocol of the current origin ('file://') is not supported.

      Code used to register service worker, as follows: (serviceworker.js is an empty file)

      navigator.serviceWorker.register('./serviceworker.js')
      .then(function(registration) {
          // succeeded
      })
      .catch(function(e) {
          // failed
      });
      

      I've tried to enable support for file:// protocol by calling blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers() with file protocol:

      void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame)
      {
          new QtWebEngineCore::RenderFrameObserverQt(render_frame);
      
          // code below has been added
          static const char kFileSchemeQt[] = "file";
          blink::WebString fileScheme(base::ASCIIToUTF16(kFileSchemeQt));
          blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(fileScheme);
      }
      

      however, it gives me the following error.

      Failed to register a ServiceWorker: A bad HTTP response code (-1) was received when fetching the script.

      Did anyone try to enable service worker with success?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt_webengine_team Qt WebEngine Team
              szulak Arkadiusz Szulakiewicz
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: