dom/workers/test/test_blobConstructor.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!--
michael@0 2 Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 -->
michael@0 5 <!DOCTYPE html>
michael@0 6 <html>
michael@0 7 <!--
michael@0 8 Tests of DOM Worker Blob constructor
michael@0 9 -->
michael@0 10 <head>
michael@0 11 <title>Test for DOM Worker Blob constructor</title>
michael@0 12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 14 </head>
michael@0 15 <body>
michael@0 16 <p id="display"></p>
michael@0 17 <div id="content" style="display: none">
michael@0 18
michael@0 19 </div>
michael@0 20 <pre id="test">
michael@0 21 <script class="testbody" type="text/javascript">
michael@0 22 (function() {
michael@0 23 onerror = function(e) {
michael@0 24 ok(false, "Main Thread had an error: " + event.data);
michael@0 25 SimpleTest.finish();
michael@0 26 };
michael@0 27 function f() {
michael@0 28 onmessage = function(e) {
michael@0 29 var b = new Blob([e.data, "World"],{type: "text/plain"});
michael@0 30 var fr = new FileReaderSync();
michael@0 31 postMessage({text: fr.readAsText(b), type: b.type});
michael@0 32 };
michael@0 33 }
michael@0 34 var b = new Blob([f,"f();"]);
michael@0 35 var u = URL.createObjectURL(b);
michael@0 36 var w = new Worker(u);
michael@0 37 w.onmessage = function(e) {
michael@0 38 URL.revokeObjectURL(u);
michael@0 39 is(e.data.text, fr.result);
michael@0 40 is(e.data.type, "text/plain");
michael@0 41 SimpleTest.finish();
michael@0 42 };
michael@0 43 w.onerror = function(e) {
michael@0 44 is(e.target, w);
michael@0 45 ok(false, "Worker had an error: " + e.data);
michael@0 46 SimpleTest.finish();
michael@0 47 };
michael@0 48
michael@0 49 b = new Blob(["Hello, "]);
michael@0 50 var fr = new FileReader();
michael@0 51 fr.readAsText(new Blob([b, "World"],{}));
michael@0 52 fr.onload = function() {
michael@0 53 w.postMessage(b);
michael@0 54 };
michael@0 55 SimpleTest.waitForExplicitFinish();
michael@0 56 })();
michael@0 57 </script>
michael@0 58 </pre>
michael@0 59 </body>
michael@0 60 </html>

mercurial