browser_test_nsIAccessibleDocument_URL.js (1610B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 async function promiseEventDocumentLoadComplete(expectedURL) { 7 return new Promise(resolve => { 8 waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, event => { 9 try { 10 if ( 11 event.accessible.QueryInterface(nsIAccessibleDocument).URL == 12 expectedURL 13 ) { 14 resolve(event.accessible.QueryInterface(nsIAccessibleDocument)); 15 return true; 16 } 17 return false; 18 } catch (e) { 19 return false; 20 } 21 }); 22 }); 23 } 24 25 add_task(async function testInDataURI() { 26 const kURL = "data:text/html,Some text"; 27 const waitForDocumentLoadComplete = promiseEventDocumentLoadComplete(""); 28 await BrowserTestUtils.withNewTab(kURL, async () => { 29 is( 30 (await waitForDocumentLoadComplete).URL, 31 "", 32 "nsIAccessibleDocument.URL shouldn't return data URI" 33 ); 34 }); 35 }); 36 37 add_task(async function testInHTTPSURIContainingPrivateThings() { 38 const kURL = 39 "https://username:password@example.com/browser/toolkit/content/tests/browser/file_empty.html?query=some#ref"; 40 const kURLWithoutUserPass = 41 "https://example.com/browser/toolkit/content/tests/browser/file_empty.html?query=some#ref"; 42 const waitForDocumentLoadComplete = 43 promiseEventDocumentLoadComplete(kURLWithoutUserPass); 44 await BrowserTestUtils.withNewTab(kURL, async () => { 45 is( 46 (await waitForDocumentLoadComplete).URL, 47 kURLWithoutUserPass, 48 "nsIAccessibleDocument.URL shouldn't contain user/pass section" 49 ); 50 }); 51 });