Skip to content

Commit

Permalink
Reverting most server changes due to web-platform-tests#4210
Browse files Browse the repository at this point in the history
  • Loading branch information
jakearchibald committed Aug 4, 2017
1 parent 4552339 commit 08ec024
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 53 deletions.
14 changes: 2 additions & 12 deletions docs/_writing-tests/testharness.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ creating a `FileAPI/FileReaderSync.worker.js` as follows:

This test could then be run from `FileAPI/FileReaderSync.worker.html`.

In addition to `.worker.js`, the following worker type extensions are
supported:

* Shared workers: `.sharedworker.js`, mapping to `.sharedworker.html`.
* Service workers: `.serviceworker.js`, mapping to `.serviceworker.html`.

### Multi-global tests

Tests for features that exist in multiple global scopes can be written
Expand All @@ -83,12 +77,8 @@ creating a `FileAPI/Blob-constructor.any.js` as follows:
assert_false(blob.isClosed);
}, "The Blob constructor.");

This test could then be run from:

* `FileAPI/Blob-constructor.any.html`.
* `FileAPI/Blob-constructor.any.worker.html`.
* `FileAPI/Blob-constructor.any.sharedworker.html`.
* `FileAPI/Blob-constructor.any.serviceworker.https.html`.
This test could then be run from `FileAPI/Blob-constructor.any.worker.html` as well
as `FileAPI/Blob-constructor.any.html`.

To check if your test is run from a window or worker you can use the following two methods that will
be made available by the framework:
Expand Down
23 changes: 23 additions & 0 deletions fetch/api/abort/general-serviceworker.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>General fetch abort tests in a service worker</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
(async function() {
const scope = 'does/not/exist';

let reg = await navigator.serviceWorker.getRegistration(scope);
if (reg) await reg.unregister();

reg = await navigator.serviceWorker.register('general.any.worker.js', {scope});

fetch_tests_from_worker(reg.installing);
})();
</script>
</body>
</html>
14 changes: 14 additions & 0 deletions fetch/api/abort/general-sharedworker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>General fetch abort tests - shared worker</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new SharedWorker("general.any.worker.js"));
</script>
</body>
</html>
41 changes: 0 additions & 41 deletions tools/serve/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,45 +143,6 @@ class WorkersHandler(HtmlWrapperHandler):
"""


class SharedWorkersHandler(HtmlWrapperHandler):
path_replace = [(".any.sharedworker.html", ".any.js", ".any.worker.js"),
(".sharedworker.html", ".sharedworker.js")]
wrapper = """<!doctype html>
<meta charset=utf-8>
%(meta)s
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
fetch_tests_from_worker(new SharedWorker("%(path)s"));
</script>
"""


class ServiceWorkersHandler(HtmlWrapperHandler):
path_replace = [(".any.serviceworker.https.html", ".any.js", ".any.worker.js"),
(".serviceworker.https.html", ".serviceworker.js")]
wrapper = """<!doctype html>
<meta charset=utf-8>
%(meta)s
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
(async function() {
const scope = 'does/not/exist';
let reg = await navigator.serviceWorker.getRegistration(scope);
if (reg) await reg.unregister();
reg = await navigator.serviceWorker.register("%(path)s", {scope});
fetch_tests_from_worker(reg.installing);
})();
</script>
"""


class WindowHandler(HtmlWrapperHandler):
path_replace = [(".window.html", ".window.js")]
wrapper = """<!doctype html>
Expand Down Expand Up @@ -279,8 +240,6 @@ def add_mount_point(self, url_base, path):

routes = [
("GET", "*.worker.html", WorkersHandler),
("GET", "*.sharedworker.html", SharedWorkersHandler),
("GET", "*.serviceworker.https.html", ServiceWorkersHandler),
("GET", "*.window.html", WindowHandler),
("GET", "*.any.html", AnyHtmlHandler),
("GET", "*.any.worker.js", AnyWorkerHandler),
Expand Down

0 comments on commit 08ec024

Please sign in to comment.