1 description("Tests that manipulating location properties in a just-created window object does not crash. Note: Turn off pop-up blocking to run this in-browser.");
3 if (window.testRunner) {
4 testRunner.waitUntilDone();
5 testRunner.setCanOpenWindows();
8 var testWindow = open("data:text/plain,a");
10 // Note that the window does not navigate to the new URL right away, and that is a crucial element
11 // of the test. We're checking behavior when the object was just created and is not yet at its new
14 shouldBe("testWindow.location.toString()", "'about:blank'");
15 shouldBe("testWindow.location.href", "'about:blank'");
16 shouldBe("testWindow.location.protocol", "'about:'");
17 shouldBe("testWindow.location.host", "''"); // Firefox throws an exception
18 shouldBe("testWindow.location.hostname", "''"); // Firefox throws an exception
19 shouldBe("testWindow.location.port", "''");
20 shouldBe("testWindow.location.pathname", "'blank'"); // Firefox returns the empty string
21 shouldBe("testWindow.location.search", "''");
22 shouldBe("testWindow.location.hash", "''");
24 shouldBe("testWindow.location.href = 'data:text/plain,b'", "'data:text/plain,b'");
25 shouldBe("testWindow.location.protocol = 'data'", "'data'"); // Firefox throws an exception
26 shouldBe("testWindow.location.host = 'c'", "'c'"); // Firefox throws an exception
27 shouldBe("testWindow.location.hostname = 'd'", "'d'"); // Firefox throws an exception
28 shouldBe("testWindow.location.port = 'e'", "'e'"); // Firefox throws an exception
29 shouldBe("testWindow.location.pathname = 'f'", "'f'"); // Firefox throws an exception
30 shouldBe("testWindow.location.search = 'g'", "'g'");
31 shouldBe("testWindow.location.hash = 'h'", "'h'");
33 shouldBe("testWindow.location.assign('data:text/plain,i')", "undefined");
34 shouldBe("testWindow.location.replace('data:text/plain,j')", "undefined");
35 shouldBe("testWindow.location.reload()", "undefined");
37 shouldBe("testWindow.location.toString()", "'about:blank'");
38 shouldBe("testWindow.location.href", "'about:blank'");
39 shouldBe("testWindow.location.protocol", "'about:'");
40 shouldBe("testWindow.location.host", "''"); // Firefox throws an exception
41 shouldBe("testWindow.location.hostname", "''"); // Firefox throws an exception
42 shouldBe("testWindow.location.port", "''");
43 shouldBe("testWindow.location.pathname", "'blank'"); // Firefox returns the empty string
44 shouldBe("testWindow.location.search", "''");
45 shouldBe("testWindow.location.hash", "''");
49 if (window.testRunner) {
50 function doneHandler()
52 if (testWindow.closed) {
53 testRunner.notifyDone();
56 setTimeout(doneHandler, 0);