Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/load_worker.js

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 self.onmessage = function (evt) {
2 if (evt.data == "xhr") {
3 var xhr = new XMLHttpRequest();
4 xhr.open("GET", "synthesized-response.txt", true);
5 xhr.responseType = "text";
6 xhr.send();
7 xhr.onload = function (evt) {
8 postMessage(xhr.responseText);
9 };
10 xhr.onerror = function() {
11 postMessage("XHR failed!");
12 };
13 } else if (evt.data == "fetch") {
14 fetch("synthesized-response.txt")
15 .then(function(response) {
16 return response.text();
17 })
18 .then(function(data) {
19 postMessage(data);
20 })
21 .catch(function(error) {
22 postMessage("Fetch failed!");
23 });
24 } else if (evt.data == "importScripts") {
25 importScripts("synthesized-response.js");
26 } else {
27 throw "Unexpected message! " + evt.data;
28 }
29 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698