Backed out 2 changesets (bug 1532941) for mochitest failures in uriloader/exthandler/tests/mochitest/test_handlerApps.xhtml

Backed out changeset bf03fb29b472 (bug 1532941)
Backed out changeset c5190e74039c (bug 1532941)
This commit is contained in:
Dorel Luca 2019-03-14 10:47:14 +02:00
parent 994e78fd2f
commit c0b9d28960
19 changed files with 106 additions and 92 deletions

View file

@ -27,6 +27,8 @@ netwerk/test/browser/**
netwerk/test/mochitests/**
netwerk/test/unit*/**
tools/update-packaging/**
uriloader/exthandler/**
uriloader/exthandler/tests/mochitest/**
xpfe/**
# We currently have no js files in these directories, so we ignore them by

View file

@ -29,7 +29,7 @@ HandlerService.prototype = {
QueryInterface: ChromeUtils.generateQI([
Ci.nsISupportsWeakReference,
Ci.nsIHandlerService,
Ci.nsIObserver,
Ci.nsIObserver
]),
__store: null,
@ -111,6 +111,7 @@ HandlerService.prototype = {
// read all the scheme prefs into a hash
for (let schemePrefName of schemePrefList) {
let [scheme, handlerNumber, attribute] = schemePrefName.split(".");
try {
@ -139,7 +140,7 @@ HandlerService.prototype = {
let handlerApp = this.handlerAppFromSerializable(schemes[scheme][handlerNumber]);
// If there is already a handler registered with the same template
// URL, the newly added one will be ignored when saving.
possibleHandlers.appendElement(handlerApp);
possibleHandlers.appendElement(handlerApp, false);
}
this.store(protoInfo);
@ -263,17 +264,17 @@ HandlerService.prototype = {
let handler = new Proxy(
{
QueryInterface: ChromeUtils.generateQI([Ci.nsIHandlerInfo]),
type,
type: type,
get _handlerInfo() {
delete this._handlerInfo;
return this._handlerInfo = gExternalProtocolService.getProtocolHandlerInfo(type);
},
},
{
get(target, name) {
get: function(target, name) {
return target[name] || target._handlerInfo[name];
},
set(target, name, value) {
set: function(target, name, value) {
target._handlerInfo[name] = value;
},
},

View file

@ -1,8 +0,0 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/browser-test",
"plugin:mozilla/mochitest-test",
]
};

View file

@ -20,12 +20,12 @@ function HelperAppLauncherDialog() {
}
HelperAppLauncherDialog.prototype = {
show(aLauncher, aWindowContext, aReason) {
show: function(aLauncher, aWindowContext, aReason) {
ok(true, "Showing the helper app dialog");
curDialogResolve(aWindowContext);
executeSoon(() => { aLauncher.cancel(Cr.NS_ERROR_ABORT); });
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog])
};
function promiseHelperAppDialog() {
@ -60,6 +60,7 @@ add_task(async function simple_navigation() {
// opens with target="_blank" (i.e. a new tab) and ensures that we
// automatically open and close that tab.
async function testNewTab(browser) {
let targetURL = browser.currentURI.spec;
let dialogAppeared = promiseHelperAppDialog();
let tabOpened = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen").then((event) => {
return [ event.target, BrowserTestUtils.waitForTabClosing(event.target) ];

View file

@ -29,7 +29,7 @@ add_task(async function() {
let handler = handlers.queryElementAt(0, Ci.nsIHandlerApp);
ok(handler instanceof Ci.nsIWebHandlerApp, "the handler is a web handler");
is(handler.uriTemplate, "https://example.com/foobar?uri=%s",
"correct url template");
"correct url template")
protoInfo.preferredApplicationHandler = handler;
protoInfo.alwaysAskBeforeHandling = false;
const handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"].

View file

@ -10,14 +10,15 @@ Pseudo Web Handler App
<script class="testbody" type="text/javascript">
<![CDATA[
function onLoad() {
// if we have a window.opener, this must be the windowContext
// instance of this test. check that we got the URI right and clean up.
if (window.opener) {
window.opener.is(location.search,
"?uri=" + encodeURIComponent(window.opener.testURI),
window.opener.is(location.search,
"?uri=" + encodeURIComponent(window.opener.testURI),
"uri passed to web-handler app");
window.opener.SimpleTest.finish();
}
}
window.close();
}

View file

@ -8,22 +8,24 @@ var testURI = "webcal://127.0.0.1/rheeeeet.html";
const Cc = SpecialPowers.Cc;
function test() {
// set up the web handler object
var webHandler = Cc["@mozilla.org/uriloader/web-handler-app;1"].
createInstance(SpecialPowers.Ci.nsIWebHandlerApp);
webHandler.name = "Test Web Handler App";
webHandler.uriTemplate =
"https://example.com/tests/uriloader/exthandler/tests/mochitest/" +
"https://example.com/tests/uriloader/exthandler/tests/mochitest/" +
"handlerApp.xhtml?uri=%s";
// set up the uri to test with
var ioService = Services.io;
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(SpecialPowers.Ci.nsIIOService);
var uri = ioService.newURI(testURI);
// create a window, and launch the handler in it
var newWindow = window.open("", "handlerWindow", "height=300,width=300");
var windowContext = SpecialPowers.wrap(newWindow).docShell;
webHandler.launchWithURI(uri, windowContext);
// if we get this far without an exception, we've at least partly passed
@ -32,7 +34,7 @@ function test() {
// make the web browser launch in its own window/tab
webHandler.launchWithURI(uri);
// if we get this far without an exception, we've passed
ok(true, "webHandler launchWithURI (new window/tab) test started");
@ -40,9 +42,10 @@ function test() {
var localHandler = Cc["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(SpecialPowers.Ci.nsILocalHandlerApp);
localHandler.name = "Test Local Handler App";
// get a local app that we know will be there and do something sane
var osString = Services.appinfo.OS;
var osString = Cc["@mozilla.org/xre/app-info;1"].
getService(SpecialPowers.Ci.nsIXULRuntime).OS;
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(SpecialPowers.Ci.nsIDirectoryServiceProvider);
@ -50,7 +53,8 @@ function test() {
var windowsDir = dirSvc.getFile("WinD", {});
var exe = windowsDir.clone().QueryInterface(SpecialPowers.Ci.nsIFile);
exe.appendRelativePath("SYSTEM32\\HOSTNAME.EXE");
} else if (osString == "Darwin") {
} else if (osString == "Darwin") {
var localAppsDir = dirSvc.getFile("LocApp", {});
exe = localAppsDir.clone();
exe.append("iCal.app"); // lingers after the tests finish, but this seems
@ -81,18 +85,19 @@ function test() {
// if we get this far without an exception, we've passed
ok(true, "localHandler launchWithURI test");
// if we ever decide that killing iCal is the right thing to do, change
// if we ever decide that killing iCal is the right thing to do, change
// the if statement below from "NOTDarwin" to "Darwin"
if (osString == "NOTDarwin") {
var killall = Cc["@mozilla.org/file/local;1"].
createInstance(SpecialPowers.Ci.nsIFile);
killall.initWithPath("/usr/bin/killall");
var process = Cc["@mozilla.org/process/util;1"].
createInstance(SpecialPowers.Ci.nsIProcess);
process.init(killall);
var args = ["iCal"];
var args = ['iCal'];
process.run(false, args, args.length);
}

View file

@ -41,7 +41,7 @@ function createMockedObjects(createHandlerApp) {
// Proxy for the mocked MIME info for faking the read-only attributes
let mockedMIME = new Proxy(internalMockedMIME, {
get(target, property) {
get: function (target, property) {
switch (property) {
case "hasDefaultHandler":
return true;
@ -68,7 +68,7 @@ function createMockedObjects(createHandlerApp) {
targetFile: null, // never read
// PRTime is microseconds since epoch, Date.now() returns milliseconds:
timeDownloadStarted: Date.now() * 1000,
QueryInterface: ChromeUtils.generateQI([Ci.nsICancelable, Ci.nsIHelperAppLauncher]),
QueryInterface: ChromeUtils.generateQI([Ci.nsICancelable, Ci.nsIHelperAppLauncher])
};
registerCleanupFunction(function() {

View file

@ -22,7 +22,7 @@ window.onload = () => {
}
SimpleTest.finish();
};
}
</script>
</body>
</html>

View file

@ -16,7 +16,7 @@ var unsafeBidiChars = [
"\xe2\x80\xab", // RLE
"\xe2\x80\xac", // PDF
"\xe2\x80\xad", // LRO
"\xe2\x80\xae", // RLO
"\xe2\x80\xae" // RLO
];
var tests = [
@ -35,7 +35,7 @@ function replace(name, x) {
}
function sanitize(name) {
return replace(name, "_");
return replace(name, '_');
}
const INSECURE_REGISTER_PREF = "dom.registerProtocolHandler.insecure.enabled";

View file

@ -15,7 +15,7 @@ add_task(async function() {
set: [
["dom.registerContentHandler.enabled", true],
["dom.registerProtocolHandler.insecure.enabled", false],
],
]
});
let result = "registerProtocolHandler" in navigator;

View file

@ -6,13 +6,13 @@ const HELPERAPP_DIALOG_CID =
const FAKE_CID = Cc["@mozilla.org/uuid-generator;1"].
getService(Ci.nsIUUIDGenerator).generateUUID();
/* eslint-env mozilla/frame-script */
function HelperAppLauncherDialog() {}
HelperAppLauncherDialog.prototype = {
show(aLauncher, aWindowContext, aReason) {
show: function(aLauncher, aWindowContext, aReason) {
sendAsyncMessage("suggestedFileName", aLauncher.suggestedFileName);
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog])
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);

View file

@ -37,7 +37,7 @@ let unloadHandlerStore = async function() {
gHandlerService;
let promise = TestUtils.topicObserved("handlersvc-json-replace-complete");
Services.obs.notifyObservers(null, "handlersvc-json-replace");
Services.obs.notifyObservers(null, "handlersvc-json-replace", null);
await promise;
};

View file

@ -11,16 +11,18 @@ function run_test() {
// its length to make sure this hasn't happened.
var badMimeType = "text/plainÿ";
Assert.equal(badMimeType.length, 11);
try {
Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService).
getFromTypeAndExtension(badMimeType, "txt");
var type = Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService).
getFromTypeAndExtension(badMimeType, "txt");
} catch (e) {
if (!(e instanceof Ci.nsIException) ||
e.result != Cr.NS_ERROR_NOT_AVAILABLE) {
throw e;
}
// This is an expected exception, thrown if the type can't be determined
} finally {
}
// Not crashing is good enough
Assert.equal(true, true);

View file

@ -14,7 +14,8 @@ function run_test() {
const mimeService = Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService);
const categoryManager = Services.catMan;
const categoryManager = Cc["@mozilla.org/categorymanager;1"].
getService(Ci.nsICategoryManager);
// --- Test procedure ---

View file

@ -37,7 +37,7 @@ function run_test() {
function makeForwardingFunction(functionName) {
return function() {
return aWrappedObject[functionName].apply(aWrappedObject, arguments);
};
}
}
// Forward all the functions that are not explicitly overridden
@ -59,7 +59,7 @@ function run_test() {
// --- Overridden nsIWindowsRegKey interface functions ---
open(aRootKey, aRelPath, aMode) {
open: function(aRootKey, aRelPath, aMode) {
// Remember the provided root key and path
this._rootKey = aRootKey;
this._relPath = aRelPath;
@ -68,7 +68,7 @@ function run_test() {
return this._wrappedObject.open(aRootKey, aRelPath, aMode);
},
openChild(aRelPath, aMode) {
openChild: function(aRelPath, aMode) {
// Open the child key and wrap it
var innerKey = this._wrappedObject.openChild(aRelPath, aMode);
var key = new MockWindowsRegKey(innerKey);
@ -79,7 +79,7 @@ function run_test() {
return key;
},
createChild(aRelPath, aMode) {
createChild: function(aRelPath, aMode) {
// Create the child key and wrap it
var innerKey = this._wrappedObject.createChild(aRelPath, aMode);
var key = new MockWindowsRegKey(innerKey);
@ -98,7 +98,7 @@ function run_test() {
return this._wrappedObject.valueCount;
},
readStringValue(aName) {
readStringValue: function(aName) {
// If this is the key under test, return a fake value
if (this._rootKey == Ci.nsIWindowsRegKey.ROOT_KEY_CLASSES_ROOT &&
this._relPath.toLowerCase() == ".txt" &&
@ -108,7 +108,7 @@ function run_test() {
// Return the real value in the registry
return this._wrappedObject.readStringValue(aName);
},
}
};
// --- Mock nsIWindowsRegKey factory ---
@ -121,19 +121,19 @@ function run_test() {
const kMockCID = Components.ID("{9b23dfe9-296b-4740-ba1c-d39c9a16e55e}");
const kWindowsRegKeyContractID = "@mozilla.org/windows-registry-key;1";
const kWindowsRegKeyClassName = "nsWindowsRegKey";
function registerMockWindowsRegKeyFactory() {
mockWindowsRegKeyFactory = {
createInstance(aOuter, aIid) {
createInstance: function(aOuter, aIid) {
if (aOuter != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
// XXX Bug 1533719 - originalWindowsRegKeyFactory is undefined.
// eslint-disable-next-line no-undef
var innerKey = originalWindowsRegKeyFactory.createInstance(null, aIid);
var key = new MockWindowsRegKey(innerKey);
return key.QueryInterface(aIid);
},
}
};
// Preserve the original factory
@ -171,9 +171,9 @@ function run_test() {
try {
// Try and get the MIME type associated with the extension. If this
// operation does not throw an unexpected exception, the test succeeds.
Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService).
getTypeFromExtension(".txt");
var type = Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService).
getTypeFromExtension(".txt");
} catch (e) {
if (!(e instanceof Ci.nsIException) ||
e.result != Cr.NS_ERROR_NOT_AVAILABLE) {

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
//* *************************************************************************//
//**************************************************************************//
// Constants
const handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"].
@ -14,14 +14,18 @@ function run_test() {
const protoSvc = Cc["@mozilla.org/uriloader/external-protocol-service;1"].
getService(Ci.nsIExternalProtocolService);
const prefSvc = Services.prefs;
const prefSvc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
const ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
const env = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
const rootPrefBranch = prefSvc.getBranch("");
let noMailto = false;
if (mozinfo.os == "win") {
// Check mailto handler from registry.
@ -52,7 +56,7 @@ function run_test() {
}
}
//* *************************************************************************//
//**************************************************************************//
// Sample Data
// It doesn't matter whether or not this nsIFile is actually executable,
@ -62,8 +66,8 @@ function run_test() {
// from the directory service), we use the temporary directory itself.
var executable = Services.dirsvc.get("TmpD", Ci.nsIFile);
// XXX We could, of course, create an actual executable in the directory:
// executable.append("localhandler");
// if (!executable.exists())
//executable.append("localhandler");
//if (!executable.exists())
// executable.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o755);
var localHandler = Cc["@mozilla.org/uriloader/local-handler-app;1"].
@ -81,7 +85,7 @@ function run_test() {
// of one test stomping on another's data.
//* *************************************************************************//
//**************************************************************************//
// Test Default Properties
// Get a handler info for a MIME type that neither the application nor
@ -112,7 +116,7 @@ function run_test() {
// test some default protocol info properties
var haveDefaultHandlersVersion = false;
try {
try {
// If we have a defaultHandlersVersion pref, then assume that we're in the
// firefox tree and that we'll also have default handlers.
// Bug 395131 has been filed to make this test work more generically
@ -122,26 +126,26 @@ function run_test() {
haveDefaultHandlersVersion = true;
} catch (ex) {}
const kExternalWarningDefault =
const kExternalWarningDefault =
"network.protocol-handler.warn-external-default";
prefSvc.setBoolPref(kExternalWarningDefault, true);
// XXX add more thorough protocol info property checking
// no OS default handler exists
var protoInfo = protoSvc.getProtocolHandlerInfo("x-moz-rheet");
Assert.equal(protoInfo.preferredAction, protoInfo.alwaysAsk);
Assert.ok(protoInfo.alwaysAskBeforeHandling);
// OS default exists, injected default does not exist,
// OS default exists, injected default does not exist,
// explicit warning pref: false
const kExternalWarningPrefPrefix = "network.protocol-handler.warn-external.";
prefSvc.setBoolPref(kExternalWarningPrefPrefix + "http", false);
protoInfo = protoSvc.getProtocolHandlerInfo("http");
Assert.equal(0, protoInfo.possibleApplicationHandlers.length);
Assert.ok(!protoInfo.alwaysAskBeforeHandling);
// OS default exists, injected default does not exist,
// OS default exists, injected default does not exist,
// explicit warning pref: true
prefSvc.setBoolPref(kExternalWarningPrefPrefix + "http", true);
protoInfo = protoSvc.getProtocolHandlerInfo("http");
@ -179,6 +183,7 @@ function run_test() {
Assert.ok(protoInfo.alwaysAskBeforeHandling);
else
Assert.ok(!protoInfo.alwaysAskBeforeHandling);
} else {
Assert.equal(0, protoInfo.possibleApplicationHandlers.length);
Assert.ok(protoInfo.alwaysAskBeforeHandling);
@ -197,7 +202,7 @@ function run_test() {
}
//* *************************************************************************//
//**************************************************************************//
// Test Round-Trip Data Integrity
// Test round-trip data integrity by setting the properties of the handler
@ -239,9 +244,10 @@ function run_test() {
handlerTypes.splice(handlerTypes.indexOf(handler.type), 1);
}
Assert.equal(handlerTypes.length, 0);
// Make sure the handler service's remove method removes a handler record.
handlerSvc.remove(handlerInfo2);
let handlers = handlerSvc.enumerate();
handlers = handlerSvc.enumerate();
while (handlers.hasMoreElements())
Assert.notEqual(handlers.getNext().QueryInterface(Ci.nsIHandlerInfo).type,
handlerInfo2.type);
@ -332,7 +338,7 @@ function run_test() {
Assert.equal(webPossibleHandler.name, webHandler.name);
Assert.ok(webPossibleHandler.equals(webHandler));
// ////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// handler info command line parameters and equality
var localApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Ci.nsILocalHandlerApp);
@ -355,7 +361,7 @@ function run_test() {
var localApp2 = Cc["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Ci.nsILocalHandlerApp);
localApp2.executable = executable;
localApp.clearParameters();
@ -389,17 +395,17 @@ function run_test() {
Assert.ok(!localApp2.equals(localApp));
var str;
str = localApp.getParameter(0);
str = localApp.getParameter(0)
Assert.equal(str, "-test1");
str = localApp.getParameter(1);
str = localApp.getParameter(1)
Assert.equal(str, "-test2");
str = localApp.getParameter(2);
str = localApp.getParameter(2)
Assert.equal(str, "-test3");
// FIXME: test round trip integrity for a protocol.
// FIXME: test round trip integrity for a handler info with a web handler.
//* *************************************************************************//
//**************************************************************************//
// getTypeFromExtension tests
// test nonexistent extension
@ -427,7 +433,7 @@ function run_test() {
// test mailcap entries with needsterminal are ignored on non-Windows non-Mac.
if (mozinfo.os != "win" && mozinfo.os != "mac") {
env.set("PERSONAL_MAILCAP", do_get_file("mailcap").path);
env.set('PERSONAL_MAILCAP', do_get_file('mailcap').path);
handlerInfo = mimeSvc.getFromTypeAndExtension("text/plain", null);
Assert.equal(handlerInfo.preferredAction, Ci.nsIHandlerInfo.useSystemDefault);
Assert.equal(handlerInfo.defaultDescription, "sed");

View file

@ -92,10 +92,10 @@ function assertAllHandlerInfosMatchTestData() {
possibleApplicationHandlers: [{
name: "Example Default Handler",
uriTemplate: "https://www.example.com/?url=%s",
}, {
},{
name: "Example Possible Handler One",
uriTemplate: "http://www.example.com/?id=1&url=%s",
}, {
},{
name: "Example Possible Handler Two",
uriTemplate: "http://www.example.com/?id=2&url=%s",
}],
@ -126,10 +126,10 @@ function assertAllHandlerInfosMatchTestData() {
possibleApplicationHandlers: [{
name: "Example Default Handler",
uriTemplate: "https://www.example.com/?url=%s",
}, {
},{
name: "Example Possible Handler One",
uriTemplate: "http://www.example.com/?id=1&url=%s",
}, {
},{
name: "Example Possible Handler Two",
uriTemplate: "http://www.example.com/?id=2&url=%s",
}],
@ -466,7 +466,7 @@ add_task(async function test_store_deletes_properties_except_extensions() {
alwaysAskBeforeHandling: false,
fileExtensions: [
"example_two",
"example_three",
"example_three"
],
});
});
@ -537,7 +537,7 @@ function assertAllHandlerInfosMatchDefaultHandlers() {
possibleApplicationHandlers: [{
name: "Yahoo! Mail",
uriTemplate: "https://compose.mail.yahoo.com/?To=%s",
}, {
},{
name: "Gmail",
uriTemplate: "https://mail.google.com/mail/?extsrc=mailto&url=%s",
}],

View file

@ -22,7 +22,8 @@ function checkFile() {
if (gCheckExistsAttempts >= kMaxCheckExistAttempts) {
do_throw("Expected File " + tempFile.path + " does not exist after " +
kMaxCheckExistAttempts + " seconds");
} else {
}
else {
++gCheckExistsAttempts;
// Wait a bit longer then try again
do_timeout(1000, checkFile);
@ -63,12 +64,14 @@ function checkFile() {
function run_test() {
if (mozinfo.os == "mac") {
dump("INFO | test_punycodeURIs.js | Skipping test on mac, bug 599475");
dump("INFO | test_punycodeURIs.js | Skipping test on mac, bug 599475")
return;
}
// set up the uri to test with
var ioService = Services.io;
var ioService =
Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
// set up the local handler object
var localHandler =
@ -104,7 +107,7 @@ function run_test() {
envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
// For Linux
envSvc.set("LD_LIBRARY_PATH", greDir.path);
// XXX: handle windows
//XXX: handle windows
// Now tell it where we want the file.
envSvc.set("WRITE_ARGUMENT_FILE", outFile.path);