1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/test_blobConstructor.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +<!-- 1.5 + Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ 1.7 +--> 1.8 +<!DOCTYPE html> 1.9 +<html> 1.10 +<!-- 1.11 +Tests of DOM Worker Blob constructor 1.12 +--> 1.13 +<head> 1.14 + <title>Test for DOM Worker Blob constructor</title> 1.15 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.17 +</head> 1.18 +<body> 1.19 +<p id="display"></p> 1.20 +<div id="content" style="display: none"> 1.21 + 1.22 +</div> 1.23 +<pre id="test"> 1.24 +<script class="testbody" type="text/javascript"> 1.25 +(function() { 1.26 + onerror = function(e) { 1.27 + ok(false, "Main Thread had an error: " + event.data); 1.28 + SimpleTest.finish(); 1.29 + }; 1.30 + function f() { 1.31 + onmessage = function(e) { 1.32 + var b = new Blob([e.data, "World"],{type: "text/plain"}); 1.33 + var fr = new FileReaderSync(); 1.34 + postMessage({text: fr.readAsText(b), type: b.type}); 1.35 + }; 1.36 + } 1.37 + var b = new Blob([f,"f();"]); 1.38 + var u = URL.createObjectURL(b); 1.39 + var w = new Worker(u); 1.40 + w.onmessage = function(e) { 1.41 + URL.revokeObjectURL(u); 1.42 + is(e.data.text, fr.result); 1.43 + is(e.data.type, "text/plain"); 1.44 + SimpleTest.finish(); 1.45 + }; 1.46 + w.onerror = function(e) { 1.47 + is(e.target, w); 1.48 + ok(false, "Worker had an error: " + e.data); 1.49 + SimpleTest.finish(); 1.50 + }; 1.51 + 1.52 + b = new Blob(["Hello, "]); 1.53 + var fr = new FileReader(); 1.54 + fr.readAsText(new Blob([b, "World"],{})); 1.55 + fr.onload = function() { 1.56 + w.postMessage(b); 1.57 + }; 1.58 + SimpleTest.waitForExplicitFinish(); 1.59 +})(); 1.60 +</script> 1.61 +</pre> 1.62 +</body> 1.63 +</html>