summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug1198095.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/base/test/test_bug1198095.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
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.html71
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>