Bug 592859 Update browser chrome tests to only use chrome paths for mochitest to prep for android support r=ctalbert a=NPOTB

This commit is contained in:
Joel Maher 2010-09-10 10:20:38 -07:00
Родитель 1f83591a78
Коммит 8c31c92e64
35 изменённых файлов: 200 добавлений и 127 удалений

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

@ -47,7 +47,7 @@ function runOneTest() {
});
}, true);
browser.contentWindow.location =
"chrome://mochikit/content/browser/browser/base/content/test/test_bug462673.html";
var rootDir = getRootDirectory(gTestPath);
browser.contentWindow.location = rootDir + "test_bug462673.html"
}, false);
}

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

@ -1,7 +1,7 @@
function test() {
waitForExplicitFinish();
let testPath = "chrome://mochikit/content/browser/browser/base/content/test/";
let testPath = getRootDirectory(gTestPath);
let tab = gBrowser.addTab(testPath + "file_bug550565_popup.html");

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

@ -4,9 +4,19 @@
const TESTROOT = "http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
const TESTROOT2 = "http://example.org/browser/toolkit/mozapps/extensions/test/xpinstall/";
const CHROMEROOT = "chrome://mochikit/content/browser/toolkit/mozapps/extensions/test/xpinstall/";
const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
var rootDir = getRootDirectory(gTestPath);
var path = rootDir.split('/');
var chromeName = path[0] + '//' + path[2];
var croot = chromeName + "/content/browser/toolkit/mozapps/extensions/test/xpinstall/";
var jar = getJar(croot);
if (jar) {
var tmpdir = extractJarToTmp(jar);
croot = 'file://' + tmpdir.path + '/';
}
const CHROMEROOT = croot;
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
var gVersion = Services.appinfo.version;
@ -313,8 +323,11 @@ function test_url() {
function test_localfile() {
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIChromeRegistry);
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "corrupt.xpi")).spec;
try {
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "corrupt.xpi")).spec;
} catch (ex) {
var path = CHROMEROOT + "corrupt.xpi";
}
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.loadURI(path);

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

@ -19,7 +19,8 @@ function test() {
event.currentTarget.removeEventListener("load", arguments.callee, true);
iconDiscovery();
}, true);
content.location = "chrome://mochikit/content/browser/browser/base/content/test/discovery.html";
var rootDir = getRootDirectory(gTestPath);
content.location = rootDir + "discovery.html";
}
var iconDiscoveryTests = [
@ -56,8 +57,9 @@ function iconDiscovery() {
var head = doc().getElementById("linkparent");
var link = doc().createElement("link");
var rootDir = getRootDirectory(gTestPath);
var rel = test.rel || "icon";
var href = test.href || "chrome://mochikit/content/browser/browser/base/content/test/moz.png";
var href = test.href || rootDir + "/moz.png";
var type = test.type || "image/png";
if (test.pass == undefined)
test.pass = true;

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

@ -4,8 +4,8 @@ function test() {
var tab = gBrowser.addTab();
gBrowser.selectedTab = tab;
tab.linkedBrowser.addEventListener("load", checkPageStyleMenu, true);
content.location =
"chrome://mochikit/content/browser/browser/base/content/test/page_style_sample.html";
let rootDir = getRootDirectory(gTestPath);
content.location = rootDir + "page_style_sample.html";
}
function checkPageStyleMenu() {

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

@ -1,4 +1,5 @@
const gTestRoot = "chrome://mochikit/content/browser/browser/base/content/test/";
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir;
var gTestBrowser = null;
var gNextTest = null;

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

@ -4,7 +4,7 @@
<title>Test file for bug 550565.</title>
<!--Set a favicon; that's the whole point of this file.-->
<link rel="icon" href="chrome://mochikit/content/browser/browser/base/content/test/file_bug550565_favicon.ico">
<link rel="icon" href="file_bug550565_favicon.ico">
</head>
<body>
Test file for bug 550565.

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

@ -38,7 +38,14 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_pane_visibility,

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

@ -38,7 +38,14 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_historymode_retention("remember", undefined),

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

@ -38,7 +38,13 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_custom_retention("rememberHistory", "remember"),

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

@ -38,7 +38,13 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_custom_retention("acceptCookies", "remember"),

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

@ -38,7 +38,13 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_locbar_suggestion_retention(-1, undefined),

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

@ -38,7 +38,13 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_privatebrowsing_toggle,

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

@ -38,7 +38,13 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
test_privatebrowsing_ui,

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

@ -37,7 +37,13 @@
function test() {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(jar);
rootDir = "file://" + tmpdir.path;
}
loader.loadSubScript(rootDir + "/privacypane_tests.js", this);
run_test_subset([
// history mode should be initialized to remember

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

@ -117,8 +117,8 @@ function test() {
// Test (B) : Session data restoration between modes //
//////////////////////////////////////////////////////////////////
const testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_248970_b_sample.html";
let rootDir = getRootDirectory(gTestPath);
const testURL = rootDir + "browser_248970_b_sample.html";
const testURL2 = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser/browser_248970_b_sample.html";

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

@ -117,8 +117,8 @@ function test() {
// make sure we don't save form data at all (except for tab duplication)
gPrefService.setIntPref("browser.sessionstore.privacy_level", 2);
let testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_346337_sample.html";
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_346337_sample.html";
let tab = tabbrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);

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

@ -40,8 +40,8 @@ function test() {
waitForExplicitFinish();
let pendingCount = 1;
let testUrl = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_408470_sample.html";
let rootDir = getRootDirectory(gTestPath);
let testUrl = rootDir + "browser_408470_sample.html";
let tab = gBrowser.addTab(testUrl);
tab.linkedBrowser.addEventListener("load", function(aEvent) {

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

@ -47,8 +47,8 @@ function test() {
// make sure we do save form data
gPrefService.setIntPref("browser.sessionstore.privacy_level", 0);
let testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_454908_sample.html";
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_454908_sample.html";
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);

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

@ -42,8 +42,8 @@ function test() {
// make sure we do save form data
gPrefService.setIntPref("browser.sessionstore.privacy_level", 0);
let testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_456342_sample.xhtml";
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_456342_sample.xhtml";
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);

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

@ -22,8 +22,7 @@
var documentInjected = false;
document.getElementsByTagName("iframe")[0].onload =
function() { documentInjected = true; };
frames[0].location = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_459906_empty.html";
frames[0].location = "browser_459906_empty.html";
// ... and ensure that it has time to load
for (var c = 0; !documentInjected && c < 20; c++) {

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

@ -39,15 +39,14 @@ function test() {
waitForExplicitFinish();
let testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_sample.html";
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_463205_sample.html";
let doneURL = "done";
let mainURL = testURL;
let frame1URL = "data:text/html,<input%20id='original'>";
let frame2URL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_helper.html";
let frame2URL = rootDir + "browser_463205_helper.html";
let frame3URL = "data:text/html,mark2";
let frameCount = 0;
@ -100,8 +99,7 @@ function test() {
mainURL = testURL;
frame1URL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_helper.html";
frame2URL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_463205_helper.html";
frame2URL = rootDir + "browser_463205_helper.html";
frame3URL = "data:text/html,mark2";
frameCount = 0;

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

@ -41,8 +41,8 @@ function test() {
let uniqueValue = Math.random();
let testURL = "chrome://mochikit/content/browser/" +
"browser/components/sessionstore/test/browser/browser_485482_sample.html";
let rootDir = getRootDirectory(gTestPath);
let testURL = rootDir + "browser_485482_sample.html";
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);

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

@ -9,6 +9,9 @@ var gTabCloseCount = 0;
var gTabMoveCount = 0;
var gPageLoadCount = 0;
var rootDir = getRootDirectory(gTestPath);
const CHROMEROOT = rootDir;
function test() {
waitForExplicitFinish();
@ -21,7 +24,7 @@ function test() {
activeWin.events.addListener("TabClose", onTabClose);
activeWin.events.addListener("TabMove", onTabMove);
gPageA = activeWin.open(makeURI("chrome://mochikit/content/browser/browser/fuel/test/ContentA.html"));
gPageA = activeWin.open(makeURI(CHROMEROOT + "ContentA.html"));
gPageA.events.addListener("load", onPageAFirstLoad);
is(activeWin.tabs.length, 2, "Checking length of 'Browser.tabs' after opening 1 additional tab");
@ -30,7 +33,7 @@ function test() {
gPageA.events.removeListener("load", onPageAFirstLoad);
is(gPageA.uri.spec, event.data.uri.spec, "Checking event browser tab is equal to page A");
gPageB = activeWin.open(makeURI("chrome://mochikit/content/browser/browser/fuel/test/ContentB.html"));
gPageB = activeWin.open(makeURI(CHROMEROOT + "ContentB.html"));
gPageB.events.addListener("load", delayAfterOpen);
gPageB.focus();
@ -46,8 +49,8 @@ function test() {
function afterOpen(event) {
gPageB.events.removeListener("load", delayAfterOpen);
// check actuals
is(gPageA.uri.spec, "chrome://mochikit/content/browser/browser/fuel/test/ContentA.html", "Checking 'BrowserTab.uri' after opening");
is(gPageB.uri.spec, "chrome://mochikit/content/browser/browser/fuel/test/ContentB.html", "Checking 'BrowserTab.uri' after opening");
is(gPageA.uri.spec, CHROMEROOT + "ContentA.html", "Checking 'BrowserTab.uri' after opening");
is(gPageB.uri.spec, CHROMEROOT + "ContentB.html", "Checking 'BrowserTab.uri' after opening");
// check event
is(gTabOpenCount, 2, "Checking event handler for tab open");
@ -91,7 +94,7 @@ function test() {
// test loading new content with a frame into a tab
// the event will be checked in onPageBLoadComplete
gPageB.events.addListener("load", onPageBLoadWithFrames);
gPageB.load(makeURI("chrome://mochikit/content/browser/browser/fuel/test/ContentWithFrames.html"));
gPageB.load(makeURI(CHROMEROOT + "ContentWithFrames.html"));
}
function onPageBLoadWithFrames(event) {
@ -107,12 +110,12 @@ function test() {
// test loading new content into a tab
// the event will be checked in onPageASecondLoad
gPageA.events.addListener("load", onPageASecondLoad);
gPageA.load(makeURI("chrome://mochikit/content/browser/browser/fuel/test/ContentB.html"));
gPageA.load(makeURI(CHROMEROOT + "ContentB.html"));
}
function onPageASecondLoad(event) {
gPageA.events.removeListener("load", onPageASecondLoad);
is(gPageA.uri.spec, "chrome://mochikit/content/browser/browser/fuel/test/ContentB.html", "Checking 'BrowserTab.uri' after loading new content");
is(gPageA.uri.spec, CHROMEROOT + "ContentB.html", "Checking 'BrowserTab.uri' after loading new content");
// start testing closing tabs
// the event will be checked in afterClose

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

@ -9,7 +9,9 @@ var testPage;
function test() {
testPage = Application.activeWindow.open(url("about:blank"));
testPage.events.addListener("load", afterOpen);
testPage.load(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
var rootDir = getRootDirectory(gTestPath);
testPage.load(url(rootDir + "test-form_sjis.html"));
testPage.focus();
waitForExplicitFinish();

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

@ -42,7 +42,9 @@ function test() {
var activeWin = Application.activeWindow;
testPage = activeWin.open(url("about:blank"));
testPage.events.addListener("load", afterOpen);
testPage.load(url("chrome://mochikit/content/browser/docshell/test/browser/test-form_sjis.html"));
var rootDir = getRootDirectory(gTestPath);
testPage.load(url(rootDir + "test-form_sjis.html"));
testPage.focus();
waitForExplicitFinish();

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

@ -14,7 +14,9 @@ function test() {
theTab = gBrowser.addTab();
theBrowser = gBrowser.getBrowserForTab(theTab);
theBrowser.addEventListener("load", listener, true);
theBrowser.contentWindow.location = "chrome://mochikit/content/browser/layout/style/test/bug453896_iframe.html";
var rootDir = getRootDirectory(gTestPath);
theBrowser.contentWindow.location = rootDir + "bug453896_iframe.html";
}
function doTest() {

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

@ -46,6 +46,7 @@
width="1024">
<script src="chrome://mochikit/content/tests/SimpleTest/MozillaFileLogger.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/quit.js"/>
<script src="chrome://mochikit/content/chrome-harness.js"/>
<style xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
#results {
margin: 5px;
@ -88,6 +89,11 @@
}
]]></style>
<script type="application/javascript;version=1.7"><![CDATA[
if (Cc === undefined) {
var Cc = Components.classes;
var Ci = Components.interfaces;
}
var gConfig;
var gDumper = {
@ -162,24 +168,6 @@
return eval(config);
}
function getChromeDir() {
const Cc = Components.classes; const Ci = Components.interfaces;
/** Find our chrome dir **/
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chromeURI = ios.newURI("chrome://mochikit/content/",
null, null);
var resolvedURI = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry).
convertChromeURL(chromeURI);
var fileHandler = Cc["@mozilla.org/network/protocol;1?name=file"].
getService(Ci.nsIFileProtocolHandler);
var chromeDir = fileHandler.getFileFromURLSpec(resolvedURI.spec);
return chromeDir.parent.QueryInterface(Ci.nsILocalFile);
}
function browserTest(aTestFile) {
this.path = aTestFile;
this.dumper = gDumper;
@ -220,49 +208,19 @@
// Returns an array of browserTest objects for all the selected tests
function listTests() {
const Cc = Components.classes; const Ci = Components.interfaces;
var ioSvc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var testsDir = getChromeDir();
testsDir.appendRelativePath("browser");
var requestPath = "chrome://mochikit/content/browser";
var fileNameRegexp = /browser_.+\.js$/;
if (gConfig.testPath) {
var testsDirURI = ioSvc.newFileURI(testsDir);
testsDir = ioSvc.newURI(gConfig.testPath, null, testsDirURI)
.QueryInterface(Ci.nsIFileURL).file;
// Invalid testPath...
if (!testsDir.exists())
return [];
// If we were passed a specific file, run only that test.
if (testsDir.isFile()) {
if (fileNameRegexp.test(testsDir.leafName))
return [new browserTest(requestPath + "/" + gConfig.testPath)];
// We were passed a file that's not a test...
return [];
}
// otherwise, we were passed a directory of tests
requestPath += "/" + gConfig.testPath;
}
// load server.js in so we can share template functions
var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
var srvScope = {};
scriptLoader.loadSubScript("chrome://mochikit/content/server.js", srvScope);
var baseURL = 'chrome://mochikit/content';
scriptLoader.loadSubScript('chrome://mochikit/content/server.js', srvScope);
var [links, singleTestPath] = getFileListing(baseURL, gConfig.testPath, "browser", srvScope);
var [links, ] = srvScope.list(requestPath, testsDir, true);
var fileNames = [];
var fileNameRegexp = /browser_.+\.js$/;
srvScope.arrayOfTestFiles(links, fileNames, fileNameRegexp);
return fileNames.map(function (f) new browserTest(f));
}
@ -277,7 +235,6 @@
setStatus("Running...");
testWin.focus();
var Tester = new testWin.Tester(listTests(), gDumper, testsFinished);
Tester.start();
}

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

@ -23,6 +23,7 @@ function testOnLoad() {
var sstring = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
sstring.data = location.search;
ww.openWindow(window, "chrome://mochikit/content/browser-harness.xul", "browserTest",
"chrome,centerscreen,dialog,resizable,titlebar,toolbar=no,width=800,height=600", sstring);
}
@ -194,11 +195,18 @@ Tester.prototype = {
// Import utils in the test scope.
this.currentTest.scope.EventUtils = this.EventUtils;
this.currentTest.scope.SimpleTest = this.SimpleTest;
this.currentTest.scope.gTestPath = this.currentTest.path;
// Override SimpleTest methods with ours.
["ok", "is", "isnot", "todo", "todo_is", "todo_isnot"].forEach(function(m) {
this.SimpleTest[m] = this[m];
}, this.currentTest.scope);
//load the tools to work with chrome .jar and remote
try {
this._scriptLoader.loadSubScript("chrome://mochikit/content/chrome-harness.js", this.currentTest.scope);
} catch (ex) { /* no chrome-harness tools */ }
// Import head.js script if it exists.
var currentTestDirPath =
this.currentTest.path.substr(0, this.currentTest.path.lastIndexOf("/"));
@ -346,6 +354,10 @@ function testScope(aTester, aTest) {
self.__timeoutFactor = aFactor;
};
this.copyToProfile = function test_copyToProfile(filename) {
self.SimpleTest.copyToProfile(filename);
};
this.finish = function test_finish() {
self.__done = true;
if (self.__waitTimer) {

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

@ -49,9 +49,10 @@ function test() {
// Import the toolkit test support library in the scope of the current test.
// This operation also defines the common constants Cc, Ci, Cu, Cr and Cm.
var rootDir = getRootDirectory(gTestPath);
Components.classes["@mozilla.org/moz/jssubscript-loader;1"].
getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript(
"chrome://mochikit/content/browser/toolkit/content/tests/browser/common/_loadAll.js",
rootDir + "common/_loadAll.js",
this);
// --- Test implementation ---

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

@ -47,8 +47,8 @@ const Cm = Components.manager;
// Execute the following code while keeping the current scope clean.
void(function (scriptScope) {
const kBaseUrl =
"chrome://mochikit/content/browser/toolkit/content/tests/browser/common/";
var rootDir = getRootDirectory(gTestPath);
const kBaseUrl = rootDir + "common/";
// If you add files here, add them to "Makefile.in" too.
var scriptNames = [
@ -69,4 +69,4 @@ void(function (scriptScope) {
// being executed, which is not necessarily the global scope.
scriptLoader.loadSubScript(kBaseUrl + scriptName, scriptScope);
}
}(this));
}(this));

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

@ -10,12 +10,19 @@ const RELATIVE_DIR = "browser/toolkit/mozapps/extensions/test/browser/";
const TESTROOT = "http://example.com/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/" + RELATIVE_DIR;
const CHROMEROOT = "chrome://mochikit/content/" + RELATIVE_DIR;
const MANAGER_URI = "about:addons";
const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const PREF_SEARCH_MAXRESULTS = "extensions.getAddons.maxResults";
const CHROME_NAME = "mochikit";
function getChromeRoot(path) {
if (path === undefined) {
return "chrome://" + CHROME_NAME + "/content/" + RELATIVE_DIR;
}
return getRootDirectory(path);
}
var gPendingTests = [];
var gTestsRun = 0;
@ -52,23 +59,19 @@ function run_next_test() {
}
function get_addon_file_url(aFilename) {
var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://mochikit/content/chrome-harness.js");
var jar = getJar(CHROMEROOT + "addons/" + aFilename);
if (jar == null) {
var chromeroot = getChromeRoot(gTestPath);
try {
var cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry);
var fileurl = cr.convertChromeURL(makeURI(CHROMEROOT + "addons/" + aFilename));
var fileurl = cr.convertChromeURL(makeURI(chromeroot + "addons/" + aFilename));
return fileurl.QueryInterface(Ci.nsIFileURL);
} else {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
} catch(ex) {
var jar = getJar(chromeroot + "addons/" + aFilename);
var tmpDir = extractJarToTmp(jar);
tmpDir.append(aFilename);
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
return ios.newFileURI(tmpDir).QueryInterface(Ci.nsIFileURL);
}
}

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

@ -7,10 +7,15 @@ function test() {
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIChromeRegistry);
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "unsigned.xpi")).spec;
var chromeroot = extractChromeRoot(gTestPath);
try {
var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec;
} catch (ex) {
var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted
}
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.loadURI(path);
gBrowser.loadURI(xpipath);
}
function install_ended(install, addon) {

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

@ -6,10 +6,16 @@ function test() {
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIChromeRegistry);
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "unsigned.xpi")).spec;
var chromeroot = getChromeRoot(gTestPath);
try {
var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec;
} catch (ex) {
var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted
}
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": path
"Unsigned XPI": xpipath
}));
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {

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

@ -2,12 +2,29 @@ const RELATIVE_DIR = "toolkit/mozapps/extensions/test/xpinstall/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/browser/" + RELATIVE_DIR;
const CHROMEROOT = "chrome://mochikit/content/browser/" + RELATIVE_DIR;
const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PROMPT_URL = "chrome://global/content/commonDialog.xul";
const ADDONS_URL = "chrome://mozapps/content/extensions/extensions.xul";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const PREF_INSTALL_REQUIREBUILTINCERTS = "extensions.install.requireBuiltInCerts";
const CHROME_NAME = "mochikit";
function getChromeRoot(path) {
if (path === undefined) {
return "chrome://" + CHROME_NAME + "/content/browser/" + RELATIVE_DIR
}
return getRootDirectory(path);
}
function extractChromeRoot(path) {
var path = getChromeRoot(path);
var jar = getJar(path);
if (jar) {
var tmpdir = extractJarToTmp(jar);
return "file://" + tmpdir.path + "/";
}
return path;
}
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");