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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/load_worker.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/load_worker.js b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/load_worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..2c80f25a3db2831f4b1e5633a455481d7a35b4c7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/load_worker.js
@@ -0,0 +1,29 @@
+self.onmessage = function (evt) {
+ if (evt.data == "xhr") {
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "synthesized-response.txt", true);
+ xhr.responseType = "text";
+ xhr.send();
+ xhr.onload = function (evt) {
+ postMessage(xhr.responseText);
+ };
+ xhr.onerror = function() {
+ postMessage("XHR failed!");
+ };
+ } else if (evt.data == "fetch") {
+ fetch("synthesized-response.txt")
+ .then(function(response) {
+ return response.text();
+ })
+ .then(function(data) {
+ postMessage(data);
+ })
+ .catch(function(error) {
+ postMessage("Fetch failed!");
+ });
+ } else if (evt.data == "importScripts") {
+ importScripts("synthesized-response.js");
+ } else {
+ throw "Unexpected message! " + evt.data;
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698