<!--
Thanks for opening an issue! A few things to keep in mind:

- The issue tracker is only for bugs and feature requests.
- Before reporting a bug, please try reproducing your issue against
  the latest version of Electron.
- If you need general advice, join our Slack: http://atom-slack.herokuapp.com
-->

@deepak1556 This is the issue I mentioned on Slack, thanks for your help!

* Electron version: v1.6.6
* Operating system: OSX 10.12.4

### Expected behavior

Service worker scripts should successfully load after defining a custom protocol interception on `file`. 

### Actual behavior

After defining an intercept function on `file` protocol by calling `interceptBufferProtocol`, service worker scripts fail to load with the error:

```
error when registering service worker TypeError: Failed to register a ServiceWorker: A bad HTTP response code (-1) was received when fetching the script. 
```

This occurs after a call to `interceptBufferProtocol` in the `electron-compile` npm package (in `lib/protocol-hook.js`. If this call is taken out or `protocol.uninterceptProtocol('file');` is called afterward, service worker scripts load correctly.

### How to reproduce

```
git clone https://github.com/concreted/esw -b test_electron_compile
npm install
electron .
```

You should see the `error when registering...` error in the browser window console.
<!-- 

Your best chance of getting this bug looked at quickly is to provide a REPOSITORY that can be cloned and run.

You can fork https://github.com/electron/electron-quick-start and include a link to the branch with your changes.

If you provide a URL, please list the commands required to clone/setup/run your repo e.g.

  $ git clone $YOUR_URL -b $BRANCH
  $ npm install
  $ npm start || electron .

-->

atom/browser/net/js_asker.h
using JavaScriptHandler =
    base::Callback<void(const base::DictionaryValue&, v8::Local<v8::Value>)>;
namespace internal {
using BeforeStartCallback =
    base::Callback<void(v8::Isolate*, v8::Local<v8::Value>)>;
using ResponseCallback =
    base::Callback<void(bool, std::unique_ptr<base::Value> options)>;
void AskForOptions(v8::Isolate* isolate,
                   const JavaScriptHandler& handler,
                   std::unique_ptr<base::DictionaryValue> request_details,
                   const BeforeStartCallback& before_start,
                   const ResponseCallback& callback);
bool IsErrorOptions(base::Value* value, int* error);
}  
template<typename RequestJob>
class JsAsker : public RequestJob {
 public:
  JsAsker(net::URLRequest* request, net::NetworkDelegate* network_delegate)
      : RequestJob(request, network_delegate), weak_factory_(this) {}
  
  void SetHandlerInfo(
      v8::Isolate* isolate,
      net::URLRequestContextGetter* request_context_getter,
      const JavaScriptHandler& handler) {
    isolate_ = isolate;
    request_context_getter_ = request_context_getter;
    handler_ = handler;
  }
  
  virtual void BeforeStartInUI(v8::Isolate*, v8::Local<v8::Value>) {}