Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* Any copyright is dedicated to the public domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Bug 795317: Test that the browser element sanitizes its URIs by removing the
5 // "unexposable" parts before sending them in the locationchange event.
7 "use strict";
8 SimpleTest.waitForExplicitFinish();
9 browserElementTestHelpers.setEnabledPref(true);
10 browserElementTestHelpers.addPermission();
12 var iframe;
14 function testPassword() {
15 function locationchange(e) {
16 var uri = e.detail;
17 is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html',
18 "Username and password shouldn't be exposed in uri.");
19 SimpleTest.finish();
20 }
22 iframe.addEventListener('mozbrowserlocationchange', locationchange);
23 iframe.src = "http://iamuser:iampassword@mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html";
24 }
26 function testWyciwyg() {
27 var locationChangeCount = 0;
29 function locationchange(e) {
30 // locationChangeCount:
31 // 0 - the first load.
32 // 1 - after document.write().
33 if (locationChangeCount == 0) {
34 locationChangeCount ++;
35 } else if (locationChangeCount == 1) {
36 var uri = e.detail;
37 is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_wyciwyg.html', "Scheme in string shouldn't be wyciwyg");
38 iframe.removeEventListener('mozbrowserlocationchange', locationchange);
39 SimpleTest.executeSoon(testPassword);
40 }
41 }
43 // file_wyciwyg.html calls document.write() to create a wyciwyg channel.
44 iframe.src = 'file_wyciwyg.html';
45 iframe.addEventListener('mozbrowserlocationchange', locationchange);
46 }
48 function runTest() {
49 iframe = document.createElement('iframe');
50 SpecialPowers.wrap(iframe).mozbrowser = true;
51 document.body.appendChild(iframe);
52 testWyciwyg();
53 }
55 addEventListener('testready', runTest);