1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/dom-level0/test_location_setters.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=639720 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 639720</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=639720">Mozilla Bug 639720</a> 1.16 +<p id="display"> 1.17 + <iframe id="f"></iframe> 1.18 +</p> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 639720 **/ 1.26 +SimpleTest.waitForExplicitFinish(); 1.27 + 1.28 +var tests = [ 1.29 + { url: "data:text/plain,1" }, 1.30 + { url: "data:text/plain,2", 1.31 + useDocument: true }, 1.32 + { prepURL: "http://www.example.com", 1.33 + url: "data:text/plain,3" } 1.34 +]; 1.35 + 1.36 +var currentTest = 0; 1.37 + 1.38 +function checkTest() { 1.39 + is($("f").contentWindow.location.href, tests[currentTest].url, 1.40 + "href of content window's location should match url of current test"); 1.41 + ++currentTest; 1.42 + runNextTest(); 1.43 +} 1.44 + 1.45 +function runCurrentTest() { 1.46 + var test = tests[currentTest]; 1.47 + $("f").onload = checkTest; 1.48 + if (test.useDocument) { 1.49 + $("f").contentDocument.location = test.url; 1.50 + } else { 1.51 + $("f").contentWindow.location = test.url; 1.52 + } 1.53 + is(typeof($("f").contentWindow.location), "object", 1.54 + "Location should not have become string"); 1.55 +} 1.56 + 1.57 +function prepComplete() { 1.58 + runCurrentTest(); 1.59 +} 1.60 + 1.61 +function runNextTest() { 1.62 + if (currentTest == tests.length) { 1.63 + SimpleTest.finish(); 1.64 + return; 1.65 + } 1.66 + 1.67 + var test = tests[currentTest]; 1.68 + if ("prepURL" in test) { 1.69 + $("f").onload = prepComplete; 1.70 + $("f").src = test.prepURL; 1.71 + return; 1.72 + } 1.73 + 1.74 + runCurrentTest(); 1.75 +} 1.76 + 1.77 +addLoadEvent(runNextTest); 1.78 +</script> 1.79 +</pre> 1.80 +</body> 1.81 +</html>