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_bug1238440.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_bug1238440.html')
-rw-r--r-- | dom/base/test/test_bug1238440.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/dom/base/test/test_bug1238440.html b/dom/base/test/test_bug1238440.html new file mode 100644 index 000000000..27cd2c0cd --- /dev/null +++ b/dom/base/test/test_bug1238440.html @@ -0,0 +1,88 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test - bug 1238440</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> + <input type="file" id="file" /> + <script type="application/javascript"> + +var script; + +function step_createScript() { + info("Creating script..."); + var url = SimpleTest.getTestFileURL("script_bug1238440.js"); + script = SpecialPowers.loadChromeScript(url); + next(); +} + +function step_destroyScript() { + info("Destroying script..."); + script.destroy(); + next(); +} + + +function step_createFile() { + info("Creating file..."); + + function onOpened(message) { + var fileList = document.getElementById('file'); + SpecialPowers.wrap(fileList).mozSetFileArray([message.file]); + ok(!!message.file, "File created and set"); + next(); + } + + script.addMessageListener("file.opened", onOpened); + script.sendAsyncMessage("file.open"); +} + +function step_changeFile() { + info("Changing file..."); + script.addMessageListener("file.changed", next); + script.sendAsyncMessage("file.change"); +} + +function step_fileReader(status) { + var fr = new FileReader(); + fr.onload = function() { + is(status, true, "onload called!"); + next(); + } + + fr.onerror = function(e) { + e.preventDefault(); + is(status, false, "onerror called!"); + next(); + } + + fr.readAsArrayBuffer(document.getElementById("file").files[0]); +} + +var steps = [ + step_createScript, + step_createFile, + function() { step_fileReader(true); }, + step_changeFile, + function() { step_fileReader(false); }, + step_destroyScript, +]; + +function next() { + if (!steps.length) { + SimpleTest.finish(); + return; + } + + var step = steps.shift(); + step(); +} + +SimpleTest.waitForExplicitFinish(); +next(); + </script> +</body> +</html> |