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

Unified Diff: LayoutTests/fast/files/resources/apply-blob-url-to-xhr.js

Issue 1240503004: Revert of [XMLHttpRequest] Stop throwing for network error in async mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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: LayoutTests/fast/files/resources/apply-blob-url-to-xhr.js
diff --git a/LayoutTests/fast/files/resources/apply-blob-url-to-xhr.js b/LayoutTests/fast/files/resources/apply-blob-url-to-xhr.js
deleted file mode 100644
index 463704be76b1f352b2e914b0e2d2bf5420a2a5ec..0000000000000000000000000000000000000000
--- a/LayoutTests/fast/files/resources/apply-blob-url-to-xhr.js
+++ /dev/null
@@ -1,97 +0,0 @@
-function log(message)
-{
- if (self.importScripts) {
- postMessage(message);
- } else {
- document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
- }
-}
-
-var uuidRegex = new RegExp('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
-
-function replaceUUID(s)
-{
- return s.replace(uuidRegex, 'UUID');
-}
-
-function sendXMLHttpRequestSync(method, url)
-{
- var xhr = new XMLHttpRequest();
- xhr.open(method, url, false);
- try {
- xhr.send();
- log("Status: " + xhr.status);
- log("Response: " + xhr.responseText);
- } catch (error) {
- log("Received exception, code: " + error.code + ", name: " + error.name + ", message: " + replaceUUID(error.message));
- }
-}
-
-function sendXMLHttpRequestAsync(method, url)
-{
- return new Promise(function (resolve) {
- var xhr = new XMLHttpRequest();
-
- xhr.onload = function()
- {
- log("Status: " + xhr.status);
- log("Response: " + xhr.responseText);
- };
- xhr.onerror = function()
- {
- log("Error event is dispatched");
- };
- xhr.onloadend = function()
- {
- resolve();
- };
-
- xhr.open(method, url, true);
- try {
- xhr.send();
- } catch (error) {
- log("Received exception, code: " + error.code + ", name: " + error.name + ", message: " + replaceUUID(error.message));
- }
- });
-}
-
-function runXHRs(file)
-{
- var fileURL = URL.createObjectURL(file);
-
- log("Test that sync XMLHttpRequest GET succeeds.");
- sendXMLHttpRequestSync("GET", fileURL);
-
- log("Test that sync XMLHttpRequest POST fails.");
- sendXMLHttpRequestSync("POST", fileURL);
-
- log("Test that sync XMLHttpRequest GET fails after the blob URL is revoked.");
- URL.revokeObjectURL(fileURL);
- sendXMLHttpRequestSync("GET", fileURL);
-
- fileURL = URL.createObjectURL(file);
-
- log("Test that async XMLHttpRequest GET succeeds.");
- sendXMLHttpRequestAsync("GET", fileURL).then(function()
- {
- log("Test that async XMLHttpRequest POST fails.");
- return sendXMLHttpRequestAsync("POST", fileURL);
- }).then(function()
- {
- log("Test that async XMLHttpRequest GET fails after the blob URL is revoked.");
- URL.revokeObjectURL(fileURL);
- return sendXMLHttpRequestAsync("GET", fileURL);
- }).then(function()
- {
- log("DONE");
- if (!self.importScripts && testRunner.notifyDone)
- testRunner.notifyDone();
- });
-}
-
-if (self.importScripts) {
- onmessage = function(event)
- {
- runXHRs(event.data);
- };
-}

Powered by Google App Engine
This is Rietveld 408576698