Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Bug 1490257 - Pass triggeringPrincipal to test code. r=ckerschb
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kingston committed Nov 5, 2018
1 parent 954571e commit f7d83c5
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 32 deletions.
10 changes: 5 additions & 5 deletions accessible/tests/browser/events/browser_test_docload.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function runTests(browser, accDoc) {
[EVENT_STATE_CHANGE, inIframeChecker("iframe1")]]
});

browser.loadURI(`data:text/html;charset=utf-8,
BrowserTestUtils.loadURI(browser, `data:text/html;charset=utf-8,
<html><body id="body2">
<iframe id="iframe1" src="http://example.com"></iframe>
</body></html>`);
Expand All @@ -54,7 +54,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)]
]);

browser.loadURI("about:about");
BrowserTestUtils.loadURI(browser, "about:about");

await onLoadEvents;

Expand All @@ -74,7 +74,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)]
]);

browser.loadURI("about:mozilla");
BrowserTestUtils.loadURI(browser, "about:mozilla");

await onLoadEvents;

Expand All @@ -94,7 +94,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)]
]);

browser.loadURI("http://www.wronguri.wronguri/");
BrowserTestUtils.loadURI(browser, "http://www.wronguri.wronguri/");

await onLoadEvents;

Expand All @@ -104,7 +104,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)]
]);

browser.loadURI("https://nocert.example.com:443/");
BrowserTestUtils.loadURI(browser, "https://nocert.example.com:443/");

await onLoadEvents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ add_task(async function contentToChromeNavigate() {
await ContentTask.spawn(tab.linkedBrowser, null, function() {
const CHROME_URL = "about:config";
let webnav = content.window.getInterface(Ci.nsIWebNavigation);
webnav.loadURI(CHROME_URL, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
webnav.loadURI(CHROME_URL, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null, systemPrincipal);
});
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

Expand Down
3 changes: 2 additions & 1 deletion docshell/test/unit/test_setUsePrivateBrowsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ add_task(async function() {
equal(loadContext.usePrivateBrowsing, false,
"Should be able to change origin attributes prior to a document load");

webNav.loadURI("data:text/html,", webNav.LOAD_FLAGS_NONE, null, null, null);
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
webNav.loadURI("data:text/html,", webNav.LOAD_FLAGS_NONE, null, null, null, systemPrincipal);

// Return to the event loop so the load can begin.
await new Promise(executeSoon);
Expand Down
7 changes: 4 additions & 3 deletions dom/base/test/chrome/test_bug430050.xul
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=430050
if (evt.target == evt.currentTarget) {
document.getElementById('b').setAttribute("src",
"data:text/plain,failed");
document.getElementById('b').loadURI('data:text/plain,succeeded',
null,
'UTF-8');
const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
document.getElementById('b').loadURI('data:text/plain,succeeded', {
triggeringPrincipal: systemPrincipal
});
document.getElementById('b').addEventListener("load", endTest);
}
}, true);
Expand Down
4 changes: 2 additions & 2 deletions dom/base/test/chrome/test_chromeOuterWindowID.xul
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ windows.
ok(nonRemote && !nonRemote.isRemoteBrowser,
"Should have found a non-remote browser in test window " + num);
remote.loadURI(page);
BrowserTestUtils.loadURI(remote, page);
await BrowserTestUtils.browserLoaded(remote);
nonRemote.loadURI(page);
BrowserTestUtils.loadURI(nonRemote, page);
await BrowserTestUtils.browserLoaded(nonRemote);
let result = {};
Expand Down
5 changes: 3 additions & 2 deletions dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</tabbox>
<script type="application/javascript" src="plugin-utils.js"/>
<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
const ok = window.opener.wrappedJSObject.ok;
const is = window.opener.wrappedJSObject.is;
const done = window.opener.wrappedJSObject.done;
Expand Down Expand Up @@ -57,10 +58,10 @@
function setup() {
progressListener1 = new ProgressListener();
browser1.addProgressListener(progressListener1, nsIWebProgress.NOTIFY_STATE_WINDOW);
browser1.loadURI(kURI, null, null);
BrowserTestUtils.loadURI(browser1, kURI);
progressListener2 = new ProgressListener();
browser2.addProgressListener(progressListener2, nsIWebProgress.NOTIFY_STATE_WINDOW);
browser2.loadURI(kURI, null, null);
BrowserTestUtils.loadURI(browser2, kURI);
}
window.addEventListener("load", setup, false);
Expand Down
3 changes: 2 additions & 1 deletion gfx/tests/browser/browser_windowless_troubleshoot_crash.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ add_task(async function test_windowlessBrowserTroubleshootCrash() {
}
Services.obs.addObserver(listener, "content-document-global-created");
});
webNav.loadURI("about:blank", 0, null, null, null);
let triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
webNav.loadURI("about:blank", 0, null, null, null, triggeringPrincipal);

await onLoaded;

Expand Down
5 changes: 4 additions & 1 deletion js/xpconnect/tests/chrome/file_bug618176.xul
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=618176
function start() {
messageManager.addMessageListener("test", recvTest);
messageManager.loadFrameScript(FRAME_SCRIPT, true);
setTimeout(function () { document.getElementById("browser").loadURI(TEST_PAGE); }, 0);
let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
setTimeout(function () {
document.getElementById("browser").loadURI(TEST_PAGE, {triggeringPrincipal});
}, 0);
}
function finish() {
Expand Down
3 changes: 2 additions & 1 deletion layout/tools/reftest/reftest-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,8 @@ function DoAssertionCheck()
function LoadURI(uri)
{
var flags = webNavigation().LOAD_FLAGS_NONE;
webNavigation().loadURI(uri, flags, null, null, null);
var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
webNavigation().loadURI(uri, flags, null, null, null, systemPrincipal);
}

function LogWarning(str)
Expand Down
3 changes: 2 additions & 1 deletion testing/mochitest/browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function testInit() {
// eslint-disable-next-line no-undef
var webNav = content.window.docShell
.QueryInterface(Ci.nsIWebNavigation);
webNav.loadURI(url, null, null, null, null);
var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
webNav.loadURI(url, null, null, null, null, systemPrincipal);
};

var listener = 'data:,function doLoad(e) { var data=e.detail&&e.detail.data;removeEventListener("contentEvent", function (e) { doLoad(e); }, false, true);sendAsyncMessage("chromeEvent", {"data":data}); };addEventListener("contentEvent", function (e) { doLoad(e); }, false, true);';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ async function loadURL(url, {frameCount}) {
Services.obs.addObserver(loadObserver, "content-document-global-created");

let webNav = Services.appShell.createWindowlessBrowser(false);
webNav.loadURI(url, 0, null, null, null);
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
webNav.loadURI(url, 0, null, null, null, systemPrincipal);

await loadPromise;

Expand Down
4 changes: 2 additions & 2 deletions toolkit/content/tests/chrome/bug263683_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
BrowserTestUtils.loadURI(gBrowser, 'data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
await promise;
await onDocumentLoaded();
}
Expand Down Expand Up @@ -140,7 +140,7 @@
// For posterity, test iframes too.
promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><iframe id="leframe" ' +
BrowserTestUtils.loadURI(gBrowser, 'data:text/html,<h2>Text mozilla</h2><iframe id="leframe" ' +
'src="data:text/html,Text mozilla"></iframe>');
await promise;
Expand Down
3 changes: 2 additions & 1 deletion toolkit/content/tests/chrome/bug304188_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
find-menu appears in editor element which has had makeEditable() called but designMode not set">

<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject);
Expand Down Expand Up @@ -52,7 +53,7 @@ find-menu appears in editor element which has had makeEditable() called but desi
});
});
});
gBrowser.loadURI("data:text/html;charset=utf-8,some%20random%20text");
BrowserTestUtils.loadURI(gBrowser, "data:text/html;charset=utf-8,some%20random%20text");
await promise;
await onDocumentLoaded();
}
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/tests/chrome/bug331215_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI("data:text/plain,latest");
BrowserTestUtils.loadURI(gBrowser, "data:text/plain,latest");
await promise;
await onDocumentLoaded();
}
Expand Down
3 changes: 2 additions & 1 deletion toolkit/content/tests/chrome/bug360437_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject);
var gFindBar = null;
Expand Down Expand Up @@ -52,7 +53,7 @@
});
});
});
gBrowser.loadURI("data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>");
BrowserTestUtils.loadURI(gBrowser, "data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>");
await promise;
await onDocumentLoaded();
}
Expand Down
3 changes: 2 additions & 1 deletion toolkit/content/tests/chrome/bug409624_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>

<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var gFindBar = null;
var gBrowser;
Expand All @@ -33,7 +34,7 @@
gFindBar = document.getElementById("FindToolbar");
gBrowser = document.getElementById("content");
gBrowser.addEventListener("pageshow", onPageShow, false);
gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
BrowserTestUtils.loadURI(gBrowser, 'data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
}
function onPageShow() {
Expand Down
3 changes: 2 additions & 1 deletion toolkit/content/tests/chrome/bug429723_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
title="429723 test">

<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var gFindBar = null;
var gBrowser;
Expand All @@ -31,7 +32,7 @@
gFindBar = document.getElementById("FindToolbar");
gBrowser = document.getElementById("content");
gBrowser.addEventListener("pageshow", onPageShow, false);
gBrowser.loadURI("data:text/html,<h2 id='h2'>mozilla</h2>");
BrowserTestUtils.loadURI(gBrowser, "data:text/html,<h2 id='h2'>mozilla</h2>");
}
setTimeout(_delayedOnLoad, 1000);
}
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/tests/chrome/bug451540_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
gBrowser.addEventListener("pageshow", onPageShow, false);
let data = `data:text/html,<input id="inp" type="text" />
<textarea id="tarea"/>`;
gBrowser.loadURI(data);
BrowserTestUtils.loadURI(gBrowser, data);
}
function promiseHighlightFinished() {
Expand Down
3 changes: 2 additions & 1 deletion toolkit/content/tests/chrome/findbar_entireword_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"/>

<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject);
Expand Down Expand Up @@ -132,7 +133,7 @@
});
});
});
gBrowser.loadURI(kBaseURL + "/sample_entireword_" + testName + ".html");
BrowserTestUtils.loadURI(gBrowser, kBaseURL + "/sample_entireword_" + testName + ".html");
await promise;
await onDocumentLoaded(testName);
}
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/tests/chrome/findbar_events_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI("data:text/html,hello there");
BrowserTestUtils.loadURI(gBrowser, "data:text/html,hello there");
await promise;
await onDocumentLoaded();
}
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/tests/chrome/findbar_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
await new Promise(resolve => setTimeout(resolve, 1000));
let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI("data:text/html,<h2 id='h2'>" + SEARCH_TEXT +
BrowserTestUtils.loadURI(gBrowser, "data:text/html,<h2 id='h2'>" + SEARCH_TEXT +
"</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2><input id='text' type='text' value='" +
SAMPLE_TEXT + "'></input><input id='button' type='button'></input><img id='img' width='50' height='50'/>");
await promise;
Expand Down
5 changes: 3 additions & 2 deletions widget/tests/test_bug428405.xul
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</tabbox>

<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
SimpleTest.waitForExplicitFinish();
Expand Down Expand Up @@ -56,7 +57,7 @@
// 6) Start reloading first tab.
function loadFirstTab() {
var browser = document.getElementById("tab1browser");
browser.loadURI("data:text/html;charset=utf-8,<body><h2>First Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,<body><h2>First Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
}
function configureFirstTab() {
Expand All @@ -81,7 +82,7 @@
// 8) Start loading second tab.
function loadSecondTab() {
var browser = document.getElementById("tab2browser");
browser.loadURI("data:text/html;charset=utf-8,<body><h2>Second Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,<body><h2>Second Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
}
function configureSecondTab() {
Expand Down

0 comments on commit f7d83c5

Please sign in to comment.