diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /widget/tests/unit | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'widget/tests/unit')
-rw-r--r-- | widget/tests/unit/test_macwebapputils.js | 44 | ||||
-rw-r--r-- | widget/tests/unit/test_taskbar_jumplistitems.js | 261 | ||||
-rw-r--r-- | widget/tests/unit/xpcshell.ini | 7 |
3 files changed, 312 insertions, 0 deletions
diff --git a/widget/tests/unit/test_macwebapputils.js b/widget/tests/unit/test_macwebapputils.js new file mode 100644 index 000000000..0701bedf0 --- /dev/null +++ b/widget/tests/unit/test_macwebapputils.js @@ -0,0 +1,44 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* 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/. */ + +//Basic tests to verify that MacWebAppUtils works + +var Ci = Components.interfaces; +var Cc = Components.classes; +var Cu = Components.utils; +var Cr = Components.results; + +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +function test_find_app() +{ + var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]. + createInstance(Ci.nsIMacWebAppUtils); + let sig = "com.apple.TextEdit"; + + let path; + path = mwaUtils.pathForAppWithIdentifier(sig); + do_print("TextEdit path: " + path + "\n"); + do_check_neq(path, ""); +} + +function test_dont_find_fake_app() +{ + var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]. + createInstance(Ci.nsIMacWebAppUtils); + let sig = "calliope.penitentiary.dramamine"; + + let path; + path = mwaUtils.pathForAppWithIdentifier(sig); + do_check_eq(path, ""); +} + + +function run_test() +{ + test_find_app(); + test_dont_find_fake_app(); +} diff --git a/widget/tests/unit/test_taskbar_jumplistitems.js b/widget/tests/unit/test_taskbar_jumplistitems.js new file mode 100644 index 000000000..d145683eb --- /dev/null +++ b/widget/tests/unit/test_taskbar_jumplistitems.js @@ -0,0 +1,261 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* 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/. */ + +// This tests taskbar jump list functionality available on win7 and up. + +var Cc = Components.classes; +var Ci = Components.interfaces; + +function test_basics() +{ + var item = Cc["@mozilla.org/windows-jumplistitem;1"]. + createInstance(Ci.nsIJumpListItem); + + var sep = Cc["@mozilla.org/windows-jumplistseparator;1"]. + createInstance(Ci.nsIJumpListSeparator); + + var shortcut = Cc["@mozilla.org/windows-jumplistshortcut;1"]. + createInstance(Ci.nsIJumpListShortcut); + + var link = Cc["@mozilla.org/windows-jumplistlink;1"]. + createInstance(Ci.nsIJumpListLink); + + do_check_false(item.equals(sep)); + do_check_false(item.equals(shortcut)); + do_check_false(item.equals(link)); + + do_check_false(sep.equals(item)); + do_check_false(sep.equals(shortcut)); + do_check_false(sep.equals(link)); + + do_check_false(shortcut.equals(item)); + do_check_false(shortcut.equals(sep)); + do_check_false(shortcut.equals(link)); + + do_check_false(link.equals(item)); + do_check_false(link.equals(sep)); + do_check_false(link.equals(shortcut)); + + do_check_true(item.equals(item)); + do_check_true(sep.equals(sep)); + do_check_true(link.equals(link)); + do_check_true(shortcut.equals(shortcut)); +} + +function test_separator() +{ + // separators: + + var item = Cc["@mozilla.org/windows-jumplistseparator;1"]. + createInstance(Ci.nsIJumpListSeparator); + + do_check_true(item.type == Ci.nsIJumpListItem.JUMPLIST_ITEM_SEPARATOR); +} + +function test_hashes() +{ + var link = Cc["@mozilla.org/windows-jumplistlink;1"] + .createInstance(Ci.nsIJumpListLink); + var uri1 = Cc["@mozilla.org/network/simple-uri;1"] + .createInstance(Ci.nsIURI); + var uri2 = Cc["@mozilla.org/network/simple-uri;1"] + .createInstance(Ci.nsIURI); + + uri1.spec = "http://www.123.com/"; + uri2.spec = "http://www.123.com/"; + + link.uri = uri1; + + do_check_true(link.compareHash(uri2)) + uri2.spec = "http://www.456.com/"; + do_check_false(link.compareHash(uri2)) + uri2.spec = "http://www.123.com/"; + do_check_true(link.compareHash(uri2)) + uri2.spec = "https://www.123.com/"; + do_check_false(link.compareHash(uri2)) + uri2.spec = "http://www.123.com/test/"; + do_check_false(link.compareHash(uri2)) + uri1.spec = "http://www.123.com/test/"; + uri2.spec = "http://www.123.com/test/"; + do_check_true(link.compareHash(uri2)) + uri1.spec = "https://www.123.com/test/"; + uri2.spec = "https://www.123.com/test/"; + do_check_true(link.compareHash(uri2)) + uri2.spec = "ftp://www.123.com/test/"; + do_check_false(link.compareHash(uri2)) + uri2.spec = "http://123.com/test/"; + do_check_false(link.compareHash(uri2)) + uri1.spec = "https://www.123.com/test/"; + uri2.spec = "https://www.123.com/Test/"; + do_check_false(link.compareHash(uri2)) + + uri1.spec = "http://www.123.com/"; + do_check_eq(link.uriHash, "QGLmWuwuTozr3tOfXSf5mg=="); + uri1.spec = "http://www.123.com/test/"; + do_check_eq(link.uriHash, "AG87Ls+GmaUYSUJFETRr3Q=="); + uri1.spec = "https://www.123.com/"; + do_check_eq(link.uriHash, "iSx6UH1a9enVPzUA9JZ42g=="); + + var uri3 = Cc["@mozilla.org/network/simple-uri;1"] + .createInstance(Ci.nsIURI); + link.uri = uri3; + do_check_eq(link.uriHash, "hTrpDwNRMkvXPqYV5kh1Fw=="); +} + +function test_links() +{ + // links: + var link1 = Cc["@mozilla.org/windows-jumplistlink;1"] + .createInstance(Ci.nsIJumpListLink); + var link2 = Cc["@mozilla.org/windows-jumplistlink;1"] + .createInstance(Ci.nsIJumpListLink); + + var uri1 = Cc["@mozilla.org/network/simple-uri;1"] + .createInstance(Ci.nsIURI); + var uri2 = Cc["@mozilla.org/network/simple-uri;1"] + .createInstance(Ci.nsIURI); + + uri1.spec = "http://www.test.com/"; + uri2.spec = "http://www.test.com/"; + + link1.uri = uri1; + link1.uriTitle = "Test"; + link2.uri = uri2; + link2.uriTitle = "Test"; + + do_check_true(link1.equals(link2)); + + link2.uriTitle = "Testing"; + + do_check_false(link1.equals(link2)); + + link2.uriTitle = "Test"; + uri2.spec = "http://www.testing.com/"; + + do_check_false(link1.equals(link2)); +} + +function test_shortcuts() +{ + // shortcuts: + var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"] + .createInstance(Ci.nsIJumpListShortcut); + + var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"] + .createInstance(Ci.nsILocalHandlerApp); + + handlerApp.name = "TestApp"; + handlerApp.detailedDescription = "TestApp detailed description."; + handlerApp.appendParameter("-test"); + + sc.iconIndex = 1; + do_check_eq(sc.iconIndex, 1); + + var faviconPageUri = Cc["@mozilla.org/network/simple-uri;1"] + .createInstance(Ci.nsIURI); + faviconPageUri.spec = "http://www.123.com/"; + sc.faviconPageUri = faviconPageUri; + do_check_eq(sc.faviconPageUri, faviconPageUri); + + var dirSvc = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties). + QueryInterface(Ci.nsIDirectoryService); + var notepad = dirSvc.get("WinD", Ci.nsIFile); + notepad.append("notepad.exe"); + if (notepad.exists()) { + handlerApp.executable = notepad; + sc.app = handlerApp; + do_check_eq(sc.app.detailedDescription, "TestApp detailed description."); + do_check_eq(sc.app.name, "TestApp"); + do_check_true(sc.app.parameterExists("-test")); + do_check_false(sc.app.parameterExists("-notset")); + } +} + +function test_jumplist() +{ + // Jump lists can't register links unless the application is the default + // protocol handler for the protocol of the link, so we skip off testing + // those in these tests. We'll init the jump list for the xpc shell harness, + // add a task item, and commit it. + + // not compiled in + if (Ci.nsIWinTaskbar == null) + return; + + var taskbar = Cc["@mozilla.org/windows-taskbar;1"] + .getService(Ci.nsIWinTaskbar); + + var builder = taskbar.createJumpListBuilder(); + + do_check_neq(builder, null); + + // Win7 and up only + try { + var sysInfo = Cc["@mozilla.org/system-info;1"]. + getService(Ci.nsIPropertyBag2); + var ver = parseFloat(sysInfo.getProperty("version")); + if (ver < 6.1) { + do_check_false(builder.available, false); + return; + } + } catch (ex) { } + + do_check_true(taskbar.available); + + builder.deleteActiveList(); + + var items = Cc["@mozilla.org/array;1"] + .createInstance(Ci.nsIMutableArray); + + var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"] + .createInstance(Ci.nsIJumpListShortcut); + + var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"] + .createInstance(Ci.nsILocalHandlerApp); + + handlerApp.name = "Notepad"; + handlerApp.detailedDescription = "Testing detailed description."; + + var dirSvc = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties). + QueryInterface(Ci.nsIDirectoryService); + var notepad = dirSvc.get("WinD", Ci.nsIFile); + notepad.append("notepad.exe"); + if (notepad.exists()) { + handlerApp.executable = notepad; + sc.app = handlerApp; + items.appendElement(sc, false); + + var removed = Cc["@mozilla.org/array;1"] + .createInstance(Ci.nsIMutableArray); + do_check_true(builder.initListBuild(removed)); + do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_TASKS, items)); + do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_RECENT)); + do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_FREQUENT)); + do_check_true(builder.commitListBuild()); + + builder.deleteActiveList(); + + do_check_true(builder.initListBuild(removed)); + do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_CUSTOM, items, "Custom List")); + do_check_true(builder.commitListBuild()); + + builder.deleteActiveList(); + } +} + +function run_test() +{ + if (mozinfo.os != "win") { + return; + } + test_basics(); + test_separator(); + test_hashes(); + test_links(); + test_shortcuts(); + test_jumplist(); +} diff --git a/widget/tests/unit/xpcshell.ini b/widget/tests/unit/xpcshell.ini new file mode 100644 index 000000000..d0e8f8701 --- /dev/null +++ b/widget/tests/unit/xpcshell.ini @@ -0,0 +1,7 @@ +[DEFAULT] +head = +tail = + +[test_taskbar_jumplistitems.js] +[test_macwebapputils.js] +skip-if = os != "mac" |