Bug 1490257 - Pass triggeringPrincipal to test code. r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D10882

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kingston 2018-11-05 14:05:47 +00:00
Родитель 3824b0d43e
Коммит 4248b4c554
22 изменённых файлов: 49 добавлений и 32 удалений

Просмотреть файл

@ -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>`);
@ -54,7 +54,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)]
]);
browser.loadURI("about:about");
BrowserTestUtils.loadURI(browser, "about:about");
await onLoadEvents;
@ -74,7 +74,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)]
]);
browser.loadURI("about:mozilla");
BrowserTestUtils.loadURI(browser, "about:mozilla");
await onLoadEvents;
@ -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;
@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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 = {};

Просмотреть файл

@ -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;
@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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)

Просмотреть файл

@ -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);';

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();
}
@ -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;

Просмотреть файл

@ -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);
@ -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();
}

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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;
@ -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();
}

Просмотреть файл

@ -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;
@ -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() {

Просмотреть файл

@ -14,6 +14,7 @@
title="429723 test">
<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var gFindBar = null;
var gBrowser;
@ -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);
}

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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);
@ -132,7 +133,7 @@
});
});
});
gBrowser.loadURI(kBaseURL + "/sample_entireword_" + testName + ".html");
BrowserTestUtils.loadURI(gBrowser, kBaseURL + "/sample_entireword_" + testName + ".html");
await promise;
await onDocumentLoaded(testName);
}

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -23,6 +23,7 @@
</tabbox>
<script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
SimpleTest.waitForExplicitFinish();
@ -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() {
@ -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() {