Created
July 23, 2021 18:04
-
-
Save dotproto/83f8354b452472576272966ea4b09c6e to your computer and use it in GitHub Desktop.
Manifest V3 importScripts try/catch demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2021 Google LLC | |
// | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file or at | |
// https://developers.google.com/open-source/licenses/bsd | |
// Use importScripts to load other JS files | |
importScripts('./lib.js'); | |
console.log(self.demo.greeting); | |
/* | |
* Uncomment this block and reload the extension to see how errors are | |
* handled. Currently (as of 2021-07-23) the extension's error page will | |
* log "SyntaxError: Unexpected end of input", but the console will contain | |
* a more detailed log message showing what error was thrown and where. | |
*/ | |
// throw new Error('Testing error handling'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2021 Google LLC | |
// | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file or at | |
// https://developers.google.com/open-source/licenses/bsd | |
try { | |
importScripts('./background.js'); | |
} catch (e) { | |
console.error(e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2021 Google LLC | |
// | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file or at | |
// https://developers.google.com/open-source/licenses/bsd | |
self.demo = { | |
greeting: 'Hello, world!' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "importScripts try/catch demo", | |
"version": "1.0", | |
"manifest_version": 3, | |
"background": { | |
"service_worker": "bg-wrapper.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment