-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added service worker support * chore: isolated (and skipped) implementations conflicts * chore: ran suite in service worker environment * chore: renamed sw-reporter.js to sw.reporter.js * chore: unregister sw after tests * refactor: consolidated make browser and make service-worker into make debug * chore: created cloud worker to fix XmlHttpRequest issue * chore: added debug home page * chore: added silent arg to server bin * chore: removed old sw suite runner logic * chore: updated service worker run script
- Loading branch information
Showing
16 changed files
with
258 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
.reports | ||
*.log | ||
dist | ||
ponyfill.bundle.js | ||
polyfill.bundle.js | ||
*.bundle.js | ||
|
||
# OSX | ||
# | ||
|
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
name = "cloud-worker" | ||
name = "cloud-worker-fix" | ||
main = "src/index.js" | ||
compatibility_date = "2023-05-06" |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<link href="../../../node_modules/mocha/mocha.css" rel="stylesheet" /> | ||
<style> | ||
.links li:before { | ||
content: "•"; | ||
font-size: 10px; | ||
padding: 0 10px; | ||
} | ||
|
||
.links a { | ||
color: #89cff0; | ||
font-size: 16px; | ||
font-weight: 200; | ||
text-decoration: none; | ||
} | ||
|
||
.links a:hover { | ||
text-decoration: underline; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="mocha"> | ||
<h1>Fetch API Test Suites</h1> | ||
|
||
<div class="suite"> | ||
<h1>Implementations</h1> | ||
|
||
<ul class="links"> | ||
<li><a href="./browser/">browser</a></li> | ||
<li><a href="./whatwg/">whatwg-fetch lib</a></li> | ||
<li><a href="./service-worker/">service worker</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<link href="../../../node_modules/mocha/mocha.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<div id="mocha"> | ||
<h1>Please check console!</h1> | ||
</div> | ||
|
||
<script> | ||
const registration = navigator.serviceWorker.register('/test/fetch-api/service-worker/sw.bundle.js', { | ||
scope: '/test/fetch-api/service-worker/' | ||
}) | ||
.catch(err => console.error(`Registration failed with ${error}`)); | ||
|
||
const logChannel = new BroadcastChannel('sw-logger'); | ||
logChannel.addEventListener('message', event => { | ||
console.log(...event.data); | ||
}); | ||
|
||
const resChannel = new BroadcastChannel('sw-result'); | ||
resChannel.addEventListener('message', event => { | ||
window.__mochaResult__ = JSON.parse(event.data); | ||
|
||
// Avoids manually unregister to see output in the console | ||
registration | ||
.then(reg => reg.unregister()) | ||
.catch(err => console.error(`Unregistration failed with ${error}`)); | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
. test/setup/server.sh | ||
|
||
npx webpack --config $(dirname "$0")/webpack.config.js && | ||
npx mocha-headless-chrome -f http://127.0.0.1:8000/$(dirname $0)/index.html |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable no-undef */ | ||
import fetch, { Request, Response, Headers } from '../../..' | ||
|
||
const logChannel = new BroadcastChannel('sw-logger') | ||
|
||
// Redirect all logs to top window | ||
console.log = (...args) => logChannel.postMessage(args) | ||
|
||
importScripts('../../../node_modules/mocha/mocha.js') | ||
importScripts('../../../node_modules/chai/chai.js') | ||
importScripts('./sw.reporter.js') | ||
|
||
importScripts('../api.spec.js') | ||
importScripts('../../module-system/module.spec.js') | ||
|
||
globalThis.expect = chai.expect | ||
globalThis.fetch = fetch | ||
globalThis.Request = Request | ||
globalThis.Response = Response | ||
globalThis.Headers = Headers | ||
|
||
mocha.setup({ | ||
ui: 'bdd', | ||
reporter: SWReporter | ||
}) | ||
|
||
describe('Browser:Fetch:ServiceWorker', () => { | ||
addFetchSuite() | ||
addNativeSuite({ fetch }) | ||
}) | ||
|
||
mocha.run() |
Oops, something went wrong.