dom/workers/test/test_blobConstructor.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial