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")]] [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"> <html><body id="body2">
<iframe id="iframe1" src="http://example.com"></iframe> <iframe id="iframe1" src="http://example.com"></iframe>
</body></html>`); </body></html>`);
@ -54,7 +54,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)] [EVENT_REORDER, getAccessible(browser)]
]); ]);
browser.loadURI("about:about"); BrowserTestUtils.loadURI(browser, "about:about");
await onLoadEvents; await onLoadEvents;
@ -74,7 +74,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)] [EVENT_REORDER, getAccessible(browser)]
]); ]);
browser.loadURI("about:mozilla"); BrowserTestUtils.loadURI(browser, "about:mozilla");
await onLoadEvents; await onLoadEvents;
@ -94,7 +94,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)] [EVENT_REORDER, getAccessible(browser)]
]); ]);
browser.loadURI("http://www.wronguri.wronguri/"); BrowserTestUtils.loadURI(browser, "http://www.wronguri.wronguri/");
await onLoadEvents; await onLoadEvents;
@ -104,7 +104,7 @@ async function runTests(browser, accDoc) {
[EVENT_REORDER, getAccessible(browser)] [EVENT_REORDER, getAccessible(browser)]
]); ]);
browser.loadURI("https://nocert.example.com:443/"); BrowserTestUtils.loadURI(browser, "https://nocert.example.com:443/");
await onLoadEvents; await onLoadEvents;
} }

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

@ -43,7 +43,8 @@ add_task(async function contentToChromeNavigate() {
await ContentTask.spawn(tab.linkedBrowser, null, function() { await ContentTask.spawn(tab.linkedBrowser, null, function() {
const CHROME_URL = "about:config"; const CHROME_URL = "about:config";
let webnav = content.window.getInterface(Ci.nsIWebNavigation); 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); await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

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

@ -34,7 +34,8 @@ add_task(async function() {
equal(loadContext.usePrivateBrowsing, false, equal(loadContext.usePrivateBrowsing, false,
"Should be able to change origin attributes prior to a document load"); "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. // Return to the event loop so the load can begin.
await new Promise(executeSoon); await new Promise(executeSoon);

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

@ -33,9 +33,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=430050
if (evt.target == evt.currentTarget) { if (evt.target == evt.currentTarget) {
document.getElementById('b').setAttribute("src", document.getElementById('b').setAttribute("src",
"data:text/plain,failed"); "data:text/plain,failed");
document.getElementById('b').loadURI('data:text/plain,succeeded', const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
null, document.getElementById('b').loadURI('data:text/plain,succeeded', {
'UTF-8'); triggeringPrincipal: systemPrincipal
});
document.getElementById('b').addEventListener("load", endTest); document.getElementById('b').addEventListener("load", endTest);
} }
}, true); }, true);

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

@ -83,9 +83,9 @@ windows.
ok(nonRemote && !nonRemote.isRemoteBrowser, ok(nonRemote && !nonRemote.isRemoteBrowser,
"Should have found a non-remote browser in test window " + num); "Should have found a non-remote browser in test window " + num);
remote.loadURI(page); BrowserTestUtils.loadURI(remote, page);
await BrowserTestUtils.browserLoaded(remote); await BrowserTestUtils.browserLoaded(remote);
nonRemote.loadURI(page); BrowserTestUtils.loadURI(nonRemote, page);
await BrowserTestUtils.browserLoaded(nonRemote); await BrowserTestUtils.browserLoaded(nonRemote);
let result = {}; let result = {};

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

@ -16,6 +16,7 @@
</tabbox> </tabbox>
<script type="application/javascript" src="plugin-utils.js"/> <script type="application/javascript" src="plugin-utils.js"/>
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
const ok = window.opener.wrappedJSObject.ok; const ok = window.opener.wrappedJSObject.ok;
const is = window.opener.wrappedJSObject.is; const is = window.opener.wrappedJSObject.is;
const done = window.opener.wrappedJSObject.done; const done = window.opener.wrappedJSObject.done;
@ -57,10 +58,10 @@
function setup() { function setup() {
progressListener1 = new ProgressListener(); progressListener1 = new ProgressListener();
browser1.addProgressListener(progressListener1, nsIWebProgress.NOTIFY_STATE_WINDOW); browser1.addProgressListener(progressListener1, nsIWebProgress.NOTIFY_STATE_WINDOW);
browser1.loadURI(kURI, null, null); BrowserTestUtils.loadURI(browser1, kURI);
progressListener2 = new ProgressListener(); progressListener2 = new ProgressListener();
browser2.addProgressListener(progressListener2, nsIWebProgress.NOTIFY_STATE_WINDOW); browser2.addProgressListener(progressListener2, nsIWebProgress.NOTIFY_STATE_WINDOW);
browser2.loadURI(kURI, null, null); BrowserTestUtils.loadURI(browser2, kURI);
} }
window.addEventListener("load", setup, false); window.addEventListener("load", setup, false);

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

@ -18,7 +18,8 @@ add_task(async function test_windowlessBrowserTroubleshootCrash() {
} }
Services.obs.addObserver(listener, "content-document-global-created"); 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; await onLoaded;

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

@ -30,7 +30,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=618176
function start() { function start() {
messageManager.addMessageListener("test", recvTest); messageManager.addMessageListener("test", recvTest);
messageManager.loadFrameScript(FRAME_SCRIPT, true); 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() { function finish() {

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

@ -1072,7 +1072,8 @@ function DoAssertionCheck()
function LoadURI(uri) function LoadURI(uri)
{ {
var flags = webNavigation().LOAD_FLAGS_NONE; 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) function LogWarning(str)

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

@ -88,7 +88,8 @@ function testInit() {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
var webNav = content.window.docShell var webNav = content.window.docShell
.QueryInterface(Ci.nsIWebNavigation); .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);'; 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"); Services.obs.addObserver(loadObserver, "content-document-global-created");
let webNav = Services.appShell.createWindowlessBrowser(false); 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; await loadPromise;

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

@ -56,7 +56,7 @@
gBrowser = document.getElementById(browserId); gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser; gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(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 promise;
await onDocumentLoaded(); await onDocumentLoaded();
} }
@ -140,7 +140,7 @@
// For posterity, test iframes too. // For posterity, test iframes too.
promise = BrowserTestUtils.browserLoaded(gBrowser); 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>'); 'src="data:text/html,Text mozilla"></iframe>');
await promise; await promise;

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

@ -17,6 +17,7 @@
find-menu appears in editor element which has had makeEditable() called but designMode not set"> find-menu appears in editor element which has had makeEditable() called but designMode not set">
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://testing-common/ContentTask.jsm"); ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject); 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 promise;
await onDocumentLoaded(); await onDocumentLoaded();
} }

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

@ -47,7 +47,7 @@
gBrowser = document.getElementById(browserId); gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser; gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(gBrowser); let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI("data:text/plain,latest"); BrowserTestUtils.loadURI(gBrowser, "data:text/plain,latest");
await promise; await promise;
await onDocumentLoaded(); await onDocumentLoaded();
} }

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

@ -18,6 +18,7 @@
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/ContentTask.jsm"); ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject); ContentTask.setTestScope(window.opener.wrappedJSObject);
var gFindBar = null; 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 promise;
await onDocumentLoaded(); await onDocumentLoaded();
} }

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

@ -16,6 +16,7 @@
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var gFindBar = null; var gFindBar = null;
var gBrowser; var gBrowser;
@ -33,7 +34,7 @@
gFindBar = document.getElementById("FindToolbar"); gFindBar = document.getElementById("FindToolbar");
gBrowser = document.getElementById("content"); gBrowser = document.getElementById("content");
gBrowser.addEventListener("pageshow", onPageShow, false); 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() { function onPageShow() {

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

@ -14,6 +14,7 @@
title="429723 test"> title="429723 test">
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var gFindBar = null; var gFindBar = null;
var gBrowser; var gBrowser;
@ -31,7 +32,7 @@
gFindBar = document.getElementById("FindToolbar"); gFindBar = document.getElementById("FindToolbar");
gBrowser = document.getElementById("content"); gBrowser = document.getElementById("content");
gBrowser.addEventListener("pageshow", onPageShow, false); 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); setTimeout(_delayedOnLoad, 1000);
} }

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

@ -43,7 +43,7 @@
gBrowser.addEventListener("pageshow", onPageShow, false); gBrowser.addEventListener("pageshow", onPageShow, false);
let data = `data:text/html,<input id="inp" type="text" /> let data = `data:text/html,<input id="inp" type="text" />
<textarea id="tarea"/>`; <textarea id="tarea"/>`;
gBrowser.loadURI(data); BrowserTestUtils.loadURI(gBrowser, data);
} }
function promiseHighlightFinished() { function promiseHighlightFinished() {

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

@ -20,6 +20,7 @@
src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"/> src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"/>
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://testing-common/ContentTask.jsm"); ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ContentTask.setTestScope(window.opener.wrappedJSObject); 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 promise;
await onDocumentLoaded(testName); await onDocumentLoaded(testName);
} }

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

@ -48,7 +48,7 @@
gBrowser = document.getElementById(browserId); gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser; gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(gBrowser); let promise = BrowserTestUtils.browserLoaded(gBrowser);
gBrowser.loadURI("data:text/html,hello there"); BrowserTestUtils.loadURI(gBrowser, "data:text/html,hello there");
await promise; await promise;
await onDocumentLoaded(); await onDocumentLoaded();
} }

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

@ -89,7 +89,7 @@
await new Promise(resolve => setTimeout(resolve, 1000)); await new Promise(resolve => setTimeout(resolve, 1000));
let promise = BrowserTestUtils.browserLoaded(gBrowser); 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='" + "</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'/>"); SAMPLE_TEXT + "'></input><input id='button' type='button'></input><img id='img' width='50' height='50'/>");
await promise; await promise;

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

@ -23,6 +23,7 @@
</tabbox> </tabbox>
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -56,7 +57,7 @@
// 6) Start reloading first tab. // 6) Start reloading first tab.
function loadFirstTab() { function loadFirstTab() {
var browser = document.getElementById("tab1browser"); 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() { function configureFirstTab() {
@ -81,7 +82,7 @@
// 8) Start loading second tab. // 8) Start loading second tab.
function loadSecondTab() { function loadSecondTab() {
var browser = document.getElementById("tab2browser"); 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() { function configureSecondTab() {