diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/base/test/test_bug1198095.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_bug1198095.html')
-rw-r--r-- | dom/base/test/test_bug1198095.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/base/test/test_bug1198095.html b/dom/base/test/test_bug1198095.html new file mode 100644 index 0000000000..bcc005d897 --- /dev/null +++ b/dom/base/test/test_bug1198095.html @@ -0,0 +1,71 @@ +<!DOCTYPE HTML> +<html> +<head> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1198095 +--> + <title>Test for Bug 1198095</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> + +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1198095">Mozilla Bug 1198095</a> + +<pre id="test"> +<script class="testbody" type="text/javascript"> + +var fileData1 = '1234567890'; +var fileData2 = '43210'; +var r, firstBlob; + +var openerURL = SimpleTest.getTestFileURL("file_bug1198095.js"); + +var opener = SpecialPowers.loadChromeScript(openerURL); +opener.addMessageListener("file.opened", onFileOpened); +opener.addMessageListener("file.modified", onFileModified); +opener.sendAsyncMessage("file.open", fileData1); + +function onLoadEnd1(e) { + e.target.removeEventListener('loadend', onLoadEnd1); + + is(e.target, r, "Target and r are ok"); + is(e.target.readyState, FileReader.DONE, "The file has been read."); + ok(e.target.result instanceof ArrayBuffer, "The result is an ArrayBuffer"); + + var view = new Uint8Array(e.target.result); + is(view.length, fileData1.length, "File data length matches"); + for (var i = 0; i < fileData1.length; ++i) { + is(String.fromCharCode(view[i]), fileData1[i], "Byte matches"); + } + + opener.sendAsyncMessage("file.modify", fileData2); +} + +function onError1(e) { + ok(false, "This method should not be called - error1!"); +} + +function onError2(e) { + e.target.removeEventListener('error', onError2); + SimpleTest.finish(); +} + +function onFileOpened(blob) { + firstBlob = blob; + r = new FileReader(); + r.addEventListener("loadend", onLoadEnd1); + r.addEventListener("error", onError1); + r.readAsArrayBuffer(firstBlob); +} + +function onFileModified(blob) { + r.removeEventListener('error', onError1); + r.addEventListener("error", onError2); + r.readAsArrayBuffer(firstBlob); +} + +SimpleTest.waitForExplicitFinish(); +</script> +</pre> +</body> </html> |