diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/test_bug482935.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_bug482935.html')
-rw-r--r-- | dom/base/test/test_bug482935.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/base/test/test_bug482935.html b/dom/base/test/test_bug482935.html new file mode 100644 index 000000000..17f5bfdb3 --- /dev/null +++ b/dom/base/test/test_bug482935.html @@ -0,0 +1,68 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test bug 482935</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href=" /tests/SimpleTest/test.css" /> +</head> +<body onload="onWindowLoad()"> +<script class="testbody" type="text/javascript"> + +var url = "bug482935.sjs"; + +function clearCache() { + SpecialPowers.Cc["@mozilla.org/netwerk/cache-storage-service;1"]. + getService(SpecialPowers.Ci.nsICacheStorageService). + clear(); +} + +// Tests that the response is cached if the request is cancelled +// after it has reached state 4 +function testCancelInPhase4() { + + clearCache(); + + // First request - should be loaded from server + var xhr = new XMLHttpRequest(); + xhr.addEventListener("readystatechange", function(e) { + if (xhr.readyState < xhr.DONE) return; + is(xhr.readyState, xhr.DONE, "wrong readyState"); + xhr.abort(); + SimpleTest.executeSoon(function() { + // This request was cancelled, so the responseText should be empty string + is(xhr.responseText, "", "Expected empty response to cancelled request"); + + // Second request - should be found in cache + var xhr2 = new XMLHttpRequest(); + + xhr2.addEventListener("load", function() { + is(xhr2.responseText, "0", "Received fresh value for second request"); + SimpleTest.finish(); + }, false); + + xhr2.open("GET", url); + xhr2.setRequestHeader("X-Request", "1", false); + + try { xhr2.send(); } + catch(e) { + is(xhr2.status, "200", "Exception!"); + } + }); + }, false); + + xhr.open("GET", url, true); + xhr.setRequestHeader("X-Request", "0", false); + try { xhr.send(); } + catch(e) { + is("Nothing", "Exception", "Boom: " + e); + } +} + +function onWindowLoad() { + testCancelInPhase4(); +} + +SimpleTest.waitForExplicitFinish(); +</script> +</body> +</html> |