1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/test_postMessage_transfer.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=822094 1.8 +--> 1.9 +<head><meta charset=utf-8> 1.10 + <title>postMessage transferable tests</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="browserFu.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822094">Mozilla Bug 822094</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +<iframe src="postMessage_transfer_helper.html" 1.21 + name="sameDomain"></iframe> 1.22 +<iframe src="http://example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_transfer_helper.html" 1.23 + name="crossDomain"></iframe> 1.24 + 1.25 +</div> 1.26 +<pre id="test"> 1.27 +<script class="testbody" type="application/javascript"> 1.28 + 1.29 +SimpleTest.waitForExplicitFinish(); 1.30 + 1.31 +var tests = [ 1.32 + function() { testFunc(window, "http://mochi.test:8888"); }, 1.33 + function() { testFunc(frames.sameDomain, "http://mochi.test:8888"); }, 1.34 + function() { testFunc(frames.crossDomain, "http://example.org:8000"); }, 1.35 + function() { SimpleTest.finish(); }, 1.36 +]; 1.37 + 1.38 +function testFunc(target, origin) { 1.39 + var ab = new ArrayBuffer(1); 1.40 + var cd = new ArrayBuffer(1); 1.41 + 1.42 + target.postMessage([ab, cd], origin, [ab]); 1.43 + is(ab.byteLength, 0, "ab should be neutered"); 1.44 + is(cd.byteLength, 1, "cd should not be neutered"); 1.45 + 1.46 + onmessage = function(e) { 1.47 + is(e.data[0].byteLength, 1, "ab should be transfered"); 1.48 + is(e.data[1].byteLength, 1, "cd should be cloned"); 1.49 + nextTest(); 1.50 + }; 1.51 +} 1.52 + 1.53 +function nextTest() { 1.54 + var t = tests.shift(); 1.55 + t(); 1.56 +}; 1.57 + 1.58 +onload = function() { 1.59 + nextTest(); 1.60 +}; 1.61 + 1.62 +</script> 1.63 +</pre> 1.64 +</body> 1.65 +</html>