1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/postMessage_override_helper.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 + <title>Overriding postMessage and dispatchEvent bindings</title> 1.8 + <script type="application/javascript"> 1.9 + window.postMessage = function (evt) 1.10 + { 1.11 + window.parent.postMessage("FAIL overridden postMessage called", "*"); 1.12 + }; 1.13 + 1.14 + var count = 0; 1.15 + 1.16 + function receiveMessage(evt) 1.17 + { 1.18 + count++; 1.19 + if (count == 1) 1.20 + { 1.21 + window.dispatchEvent = function(evt) 1.22 + { 1.23 + window.parent.postMessage("FAIL", "*"); 1.24 + throw "dispatchEvent threw"; 1.25 + }; 1.26 + } 1.27 + 1.28 + window.parent.postMessage(evt.data, "http://mochi.test:8888"); 1.29 + } 1.30 + 1.31 + function setup() 1.32 + { 1.33 + var target = document.getElementById("location"); 1.34 + target.textContent = location.hostname + ":" + (location.port || 80); 1.35 + } 1.36 + 1.37 + window.addEventListener("message", receiveMessage, false); 1.38 + 1.39 + window.addEventListener("load", setup, false); 1.40 + </script> 1.41 +</head> 1.42 +<body> 1.43 +<h1 id="location">No location!</h1> 1.44 +</body> 1.45 +</html>