head.js (751B)
1 /** 2 * Load a given URL in the currently selected tab 3 */ 4 async function loadURL(url, expectedURL = undefined) { 5 expectedURL = expectedURL || url; 6 7 const browser = gBrowser.selectedTab.linkedBrowser; 8 const loaded = BrowserTestUtils.browserLoaded(browser, true, expectedURL); 9 10 BrowserTestUtils.startLoadingURIString(browser, url); 11 await loaded; 12 } 13 14 /** Creates an inline URL for the given source document. */ 15 function inline(src, doctype = "html") { 16 let doc; 17 switch (doctype) { 18 case "html": 19 doc = `<!doctype html>\n<meta charset=utf-8>\n${src}`; 20 break; 21 default: 22 throw new Error("Unexpected doctype: " + doctype); 23 } 24 25 return `https://example.com/document-builder.sjs?html=${encodeURIComponent( 26 doc 27 )}`; 28 }