1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
"use strict";
var gTestTab;
var gContentAPI;
var gContentWindow;
var setDefaultBrowserCalled = false;
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
function MockShellService() {}
MockShellService.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIShellService]),
isDefaultBrowser: function(aStartupCheck, aForAllTypes) { return false; },
setDefaultBrowser: function(aClaimAllTypes, aForAllUsers) {
setDefaultBrowserCalled = true;
},
shouldCheckDefaultBrowser: false,
canSetDesktopBackground: false,
BACKGROUND_TILE : 1,
BACKGROUND_STRETCH : 2,
BACKGROUND_CENTER : 3,
BACKGROUND_FILL : 4,
BACKGROUND_FIT : 5,
setDesktopBackground: function(aElement, aPosition) {},
APPLICATION_MAIL : 0,
APPLICATION_NEWS : 1,
openApplication: function(aApplication) {},
desktopBackgroundColor: 0,
openApplicationWithURI: function(aApplication, aURI) {},
defaultFeedReader: 0,
};
var mockShellService = new MockObjectRegisterer("@mozilla.org/browser/shell-service;1",
MockShellService);
// Temporarily disabled, see note at test_setDefaultBrowser.
// mockShellService.register();
add_task(setup_UITourTest);
/* This test is disabled (bug 1180714) since the MockObjectRegisterer
is not actually replacing the original ShellService.
add_UITour_task(function* test_setDefaultBrowser() {
try {
yield gContentAPI.setConfiguration("defaultBrowser");
ok(setDefaultBrowserCalled, "setDefaultBrowser called");
} finally {
mockShellService.unregister();
}
});
*/
add_UITour_task(function* test_isDefaultBrowser() {
let shell = Components.classes["@mozilla.org/browser/shell-service;1"]
.getService(Components.interfaces.nsIShellService);
let isDefault = shell.isDefaultBrowser(false);
let data = yield getConfigurationPromise("appinfo");
is(isDefault, data.defaultBrowser, "gContentAPI result should match shellService.isDefaultBrowser");
});
|