diff options
Diffstat (limited to 'toolkit/components/aboutthirdparty/tests/xpcshell')
3 files changed, 79 insertions, 0 deletions
diff --git a/toolkit/components/aboutthirdparty/tests/xpcshell/head.js b/toolkit/components/aboutthirdparty/tests/xpcshell/head.js new file mode 100644 index 0000000000..ede1d3cc73 --- /dev/null +++ b/toolkit/components/aboutthirdparty/tests/xpcshell/head.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const kExtensionModuleName = "TestShellEx.dll"; +const kATP = Cc["@mozilla.org/about-thirdparty;1"].getService( + Ci.nsIAboutThirdParty +); diff --git a/toolkit/components/aboutthirdparty/tests/xpcshell/test_aboutthirdparty.js b/toolkit/components/aboutthirdparty/tests/xpcshell/test_aboutthirdparty.js new file mode 100644 index 0000000000..281fe42188 --- /dev/null +++ b/toolkit/components/aboutthirdparty/tests/xpcshell/test_aboutthirdparty.js @@ -0,0 +1,65 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +add_task(async () => { + Assert.equal( + kATP.lookupModuleType(kExtensionModuleName), + 0, + "lookupModuleType() returns 0 before system info is collected." + ); + + // Make sure successive calls of collectSystemInfo() do not + // cause anything bad. + const kLoopCount = 100; + const promises = []; + for (let i = 0; i < kLoopCount; ++i) { + promises.push(kATP.collectSystemInfo()); + } + + const collectSystemInfoResults = await Promise.allSettled(promises); + Assert.equal(collectSystemInfoResults.length, kLoopCount); + + for (const result of collectSystemInfoResults) { + Assert.ok( + result.status == "fulfilled", + "All results from collectSystemInfo() are resolved." + ); + } + + Assert.equal( + kATP.lookupModuleType("SHELL32.dll"), + Ci.nsIAboutThirdParty.ModuleType_ShellExtension, + "Shell32.dll is always registered as a shell extension." + ); + + Assert.equal( + kATP.lookupModuleType(""), + Ci.nsIAboutThirdParty.ModuleType_Unknown, + "Looking up an empty string succeeds and returns ModuleType_Unknown." + ); + + Assert.equal( + kATP.lookupModuleType(null), + Ci.nsIAboutThirdParty.ModuleType_Unknown, + "Looking up null succeeds and returns ModuleType_Unknown." + ); + + Assert.equal( + kATP.lookupModuleType("invalid name"), + Ci.nsIAboutThirdParty.ModuleType_Unknown, + "Looking up an invalid name succeeds and returns ModuleType_Unknown." + ); + + Assert.equal( + kATP.lookupApplication(""), + null, + "Looking up an empty string returns null." + ); + + Assert.equal( + kATP.lookupApplication("invalid path"), + null, + "Looking up an invalid path returns null." + ); +}); diff --git a/toolkit/components/aboutthirdparty/tests/xpcshell/xpcshell.ini b/toolkit/components/aboutthirdparty/tests/xpcshell/xpcshell.ini new file mode 100644 index 0000000000..7fdb13e444 --- /dev/null +++ b/toolkit/components/aboutthirdparty/tests/xpcshell/xpcshell.ini @@ -0,0 +1,4 @@ +[DEFAULT] +head = head.js + +[test_aboutthirdparty.js] |