зеркало из https://github.com/mozilla/gecko-dev.git
Bug 601143: Add loading and error states to the get add-ons view. r=Unfocused, a=blocks-betaN
try: -b do -p linux,linux64,macosx,macosx64,win32 -u xpcshell,mochitest-o -t none
This commit is contained in:
Родитель
14bfb7e7dd
Коммит
58314ef20d
|
@ -497,6 +497,8 @@ var gViewController = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.controllers.removeController(this);
|
||||
},
|
||||
|
||||
statePopped: function(e) {
|
||||
|
@ -1484,6 +1486,10 @@ var gDiscoverView = {
|
|||
// after this then it must also load the discover homepage
|
||||
loaded: false,
|
||||
_browser: null,
|
||||
_loading: null,
|
||||
_error: null,
|
||||
homepageURL: null,
|
||||
_loadListeners: [],
|
||||
|
||||
initialize: function() {
|
||||
if (Services.prefs.getPrefType(PREF_DISCOVERURL) == Services.prefs.PREF_INVALID) {
|
||||
|
@ -1493,16 +1499,37 @@ var gDiscoverView = {
|
|||
}
|
||||
|
||||
this.node = document.getElementById("discover-view");
|
||||
this._loading = document.getElementById("discover-loading");
|
||||
this._error = document.getElementById("discover-error");
|
||||
this._browser = document.getElementById("discover-browser");
|
||||
|
||||
var url = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
|
||||
.getService(Ci.nsIURLFormatter)
|
||||
.formatURLPref(PREF_DISCOVERURL);
|
||||
|
||||
var browser = gDiscoverView._browser;
|
||||
var self = this;
|
||||
|
||||
function setURL(aURL) {
|
||||
try {
|
||||
self.homepageURL = Services.io.newURI(aURL, null, null);
|
||||
} catch (e) {
|
||||
self.showError();
|
||||
notifyInitialized();
|
||||
return;
|
||||
}
|
||||
|
||||
self._browser.homePage = self.homepageURL.spec;
|
||||
self._browser.addProgressListener(self, Ci.nsIWebProgress.NOTIFY_ALL |
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||
|
||||
if (self.loaded)
|
||||
self._loadBrowser(notifyInitialized);
|
||||
else
|
||||
notifyInitialized();
|
||||
}
|
||||
|
||||
if (Services.prefs.getBoolPref(PREF_BACKGROUND_UPDATE) == false) {
|
||||
browser.homePage = url;
|
||||
setURL(url);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1520,39 +1547,122 @@ var gDiscoverView = {
|
|||
}
|
||||
});
|
||||
|
||||
browser.homePage = url + "#" + JSON.stringify(list);
|
||||
|
||||
if (gDiscoverView.loaded) {
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
notifyInitialized();
|
||||
}, true);
|
||||
browser.goHome();
|
||||
} else {
|
||||
notifyInitialized();
|
||||
}
|
||||
setURL(url + "#" + JSON.stringify(list));
|
||||
});
|
||||
},
|
||||
|
||||
show: function() {
|
||||
if (!this.loaded) {
|
||||
this.loaded = true;
|
||||
|
||||
var browser = gDiscoverView._browser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
gViewController.updateCommands();
|
||||
gViewController.notifyViewChanged();
|
||||
}, true);
|
||||
browser.goHome();
|
||||
} else {
|
||||
// If the view has loaded before and the error page is not visible then
|
||||
// there is nothing else to do
|
||||
if (this.loaded && this.node.selectedPanel != this._error) {
|
||||
gViewController.updateCommands();
|
||||
gViewController.notifyViewChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
this.loaded = true;
|
||||
|
||||
// No homepage means initialization isn't complete, the browser will get
|
||||
// loaded once initialization is complete
|
||||
if (!this.homepageURL) {
|
||||
this._loadListeners.push(gViewController.notifyViewChanged.bind(gViewController));
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadBrowser(gViewController.notifyViewChanged.bind(gViewController));
|
||||
},
|
||||
|
||||
hide: function() { },
|
||||
|
||||
showError: function() {
|
||||
this.node.selectedPanel = this._error;
|
||||
},
|
||||
|
||||
_loadBrowser: function(aCallback) {
|
||||
this.node.selectedPanel = this._loading;
|
||||
|
||||
if (aCallback)
|
||||
this._loadListeners.push(aCallback);
|
||||
|
||||
if (this._browser.currentURI.equals(this.homepageURL))
|
||||
this._browser.reload();
|
||||
else
|
||||
this._browser.goHome();
|
||||
},
|
||||
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation) {
|
||||
// Ignore the about:blank load
|
||||
if (aLocation.spec == "about:blank")
|
||||
return;
|
||||
|
||||
// If the hostname is the same as the new location's host and either the
|
||||
// default scheme is insecure or the new location is secure then continue
|
||||
// with the load
|
||||
if (aLocation.host == this.homepageURL.host &&
|
||||
(!this.homepageURL.schemeIs("https") || aLocation.schemeIs("https")))
|
||||
return;
|
||||
|
||||
// Canceling the request will send an error to onStateChange which will show
|
||||
// the error page
|
||||
aRequest.cancel(Components.results.NS_BINDING_ABORTED);
|
||||
},
|
||||
|
||||
onSecurityChange: function(aWebProgress, aRequest, aState) {
|
||||
// Don't care about security if the page is not https
|
||||
if (!this.homepageURL.schemeIs("https"))
|
||||
return;
|
||||
|
||||
// If the request was secure then it is ok
|
||||
if (aState & Ci.nsIWebProgressListener.STATE_IS_SECURE)
|
||||
return;
|
||||
|
||||
// Canceling the request will send an error to onStateChange which will show
|
||||
// the error page
|
||||
aRequest.cancel(Components.results.NS_BINDING_ABORTED);
|
||||
},
|
||||
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
// Only care about the network stop status events
|
||||
if (!(aStateFlags & (Ci.nsIWebProgressListener.STATE_IS_NETWORK)) ||
|
||||
!(aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP)))
|
||||
return;
|
||||
|
||||
// Sometimes we stop getting onLocationChange events so we must redo the
|
||||
// url tests here (bug 602256)
|
||||
var location = this._browser.currentURI;
|
||||
|
||||
// Consider the successful load of about:blank as still loading
|
||||
if (Components.isSuccessCode(aStatus) && location && location.spec == "about:blank")
|
||||
return;
|
||||
|
||||
// If there was an error loading the page or the new hostname is not the
|
||||
// same as the default hostname or the default scheme is secure and the new
|
||||
// scheme is insecure then show the error page
|
||||
if (!Components.isSuccessCode(aStatus) ||
|
||||
(aRequest && aRequest instanceof Ci.nsIHttpChannel && !aRequest.requestSucceeded) ||
|
||||
location.host != this.homepageURL.host ||
|
||||
(this.homepageURL.schemeIs("https") && !location.schemeIs("https"))) {
|
||||
this.showError();
|
||||
} else {
|
||||
// Got a successful load, make sure the browser is visible
|
||||
this.node.selectedPanel = this._browser;
|
||||
gViewController.updateCommands();
|
||||
}
|
||||
|
||||
var listeners = this._loadListeners;
|
||||
this._loadListeners = [];
|
||||
|
||||
listeners.forEach(function(aListener) {
|
||||
aListener();
|
||||
});
|
||||
},
|
||||
|
||||
onProgressChange: function() { },
|
||||
onStatusChange: function() { },
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
getSelectedAddon: function() null
|
||||
};
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
<?xml-stylesheet href="chrome://mozapps/skin/extensions/extensions.css"?>
|
||||
|
||||
<!DOCTYPE page [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd">
|
||||
%extensionsDTD;
|
||||
]>
|
||||
|
@ -252,10 +254,34 @@
|
|||
<deck id="view-port" flex="1">
|
||||
|
||||
<!-- discover view -->
|
||||
<vbox id="discover-view" flex="1" class="view-pane">
|
||||
<deck id="discover-view" flex="1" class="view-pane">
|
||||
<vbox id="discover-loading" align="center" pack="stretch" flex="1" class="alert-container">
|
||||
<spacer class="alert-spacer-before"/>
|
||||
<hbox class="alert loading" align="center">
|
||||
<image/>
|
||||
<label value="&loading.label;"/>
|
||||
</hbox>
|
||||
<spacer class="alert-spacer-after"/>
|
||||
</vbox>
|
||||
<vbox id="discover-error" align="center" pack="stretch" flex="1" class="alert-container">
|
||||
<spacer class="alert-spacer-before"/>
|
||||
<hbox>
|
||||
<spacer class="discover-spacer-before"/>
|
||||
<hbox class="alert" align="center">
|
||||
<image class="discover-logo"/>
|
||||
<vbox flex="1" align="stretch">
|
||||
<label class="discover-title">&discover.title;</label>
|
||||
<description class="discover-description">&discover.description2;</description>
|
||||
<description class="discover-footer">&discover.footer;</description>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<spacer class="discover-spacer-after"/>
|
||||
</hbox>
|
||||
<spacer class="alert-spacer-after"/>
|
||||
</vbox>
|
||||
<browser id="discover-browser" type="content" flex="1"
|
||||
disablehistory="true" homepage="about:blank"/>
|
||||
</vbox>
|
||||
</deck>
|
||||
|
||||
<!-- search view -->
|
||||
<vbox id="search-view" flex="1" class="view-pane">
|
||||
|
|
|
@ -98,6 +98,7 @@ _TEST_RESOURCES = \
|
|||
browser_install.xml \
|
||||
browser_install1_3.xpi \
|
||||
browser_eula.xml \
|
||||
discovery.html \
|
||||
redirect.sjs \
|
||||
releaseNotes.xhtml \
|
||||
$(NULL)
|
||||
|
|
|
@ -5,14 +5,38 @@
|
|||
// Tests that the discovery view loads properly
|
||||
|
||||
const PREF_BACKGROUND_UPDATE = "extensions.update.enabled";
|
||||
const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html";
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
|
||||
var gLoadCompleteCallback = null;
|
||||
|
||||
var gProgressListener = {
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
// Only care about the network stop status events
|
||||
if (!(aStateFlags & (Ci.nsIWebProgressListener.STATE_IS_NETWORK)) ||
|
||||
!(aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP)))
|
||||
return;
|
||||
|
||||
if (gLoadCompleteCallback)
|
||||
executeSoon(gLoadCompleteCallback);
|
||||
gLoadCompleteCallback = null;
|
||||
},
|
||||
|
||||
onLocationChange: function() { },
|
||||
onSecurityChange: function() { },
|
||||
onProgressChange: function() { },
|
||||
onStatusChange: function() { },
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
};
|
||||
|
||||
function test() {
|
||||
// Switch to a known url
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, TESTROOT + "releaseNotes.xhtml");
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
@ -52,6 +76,10 @@ function end_test() {
|
|||
}
|
||||
|
||||
function getURL(aBrowser) {
|
||||
if (gManagerWindow.document.getElementById("discover-view").selectedPanel !=
|
||||
aBrowser)
|
||||
return null;
|
||||
|
||||
var url = aBrowser.currentURI.spec;
|
||||
var pos = url.indexOf("#");
|
||||
if (pos != -1)
|
||||
|
@ -60,6 +88,10 @@ function getURL(aBrowser) {
|
|||
}
|
||||
|
||||
function getHash(aBrowser) {
|
||||
if (gManagerWindow.document.getElementById("discover-view").selectedPanel !=
|
||||
aBrowser)
|
||||
return null;
|
||||
|
||||
var url = aBrowser.currentURI.spec;
|
||||
var pos = url.indexOf("#");
|
||||
if (pos != -1)
|
||||
|
@ -107,6 +139,29 @@ function testHash(aBrowser, aCallback) {
|
|||
});
|
||||
}
|
||||
|
||||
function isLoading() {
|
||||
return gManagerWindow.document.getElementById("discover-view").selectedPanel ==
|
||||
gManagerWindow.document.getElementById("discover-loading");
|
||||
}
|
||||
|
||||
function isError() {
|
||||
return gManagerWindow.document.getElementById("discover-view").selectedPanel ==
|
||||
gManagerWindow.document.getElementById("discover-error");
|
||||
}
|
||||
|
||||
function clickLink(aId, aCallback) {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
browser.addProgressListener(gProgressListener);
|
||||
|
||||
gLoadCompleteCallback = function() {
|
||||
browser.removeProgressListener(gProgressListener);
|
||||
aCallback();
|
||||
};
|
||||
|
||||
var link = browser.contentDocument.getElementById(aId);
|
||||
EventUtils.sendMouseEvent({type: "click"}, link);
|
||||
}
|
||||
|
||||
// Tests that switching to the discovery view displays the right url
|
||||
add_test(function() {
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
|
@ -115,12 +170,14 @@ add_test(function() {
|
|||
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
testHash(browser, function() {
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
});
|
||||
|
||||
ok(isLoading(), "Should be loading at first");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -128,16 +185,18 @@ add_test(function() {
|
|||
// selected view displays the right url
|
||||
add_test(function() {
|
||||
open_manager(null, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
testHash(browser, function() {
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
}, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
ok(isLoading(), "Should be loading at first");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -150,16 +209,18 @@ add_test(function() {
|
|||
gCategoryUtilities.openType("extension", function() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
testHash(browser, function() {
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
}, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
ok(isLoading(), "Should be loading at first");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -180,7 +241,7 @@ add_test(function() {
|
|||
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
is(getHash(browser), null, "Hash should not have been passed");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
|
@ -197,7 +258,7 @@ add_test(function() {
|
|||
is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
is(getHash(browser), null, "Hash should not have been passed");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
|
@ -218,7 +279,7 @@ add_test(function() {
|
|||
is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
is(getHash(browser), null, "Hash should not have been passed");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
|
@ -227,3 +288,202 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that navigating to an insecure page fails
|
||||
add_test(function() {
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
clickLink("link-http", function() {
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
ok(isLoading(), "Should start loading again");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that navigating to a different domain fails
|
||||
add_test(function() {
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
clickLink("link-domain", function() {
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
ok(isLoading(), "Should start loading again");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that navigating to a missing page fails
|
||||
add_test(function() {
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
clickLink("link-bad", function() {
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
ok(isLoading(), "Should start loading again");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that navigating to a page on the same domain works
|
||||
add_test(function() {
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
clickLink("link-good", function() {
|
||||
is(getURL(browser), "https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
is(getURL(browser), "https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml", "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests repeated navigation to the same page followed by a navigation to a
|
||||
// different domain
|
||||
add_test(function() {
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
var count = 10;
|
||||
function clickAgain(aCallback) {
|
||||
if (count-- == 0)
|
||||
aCallback();
|
||||
else
|
||||
clickLink("link-normal", clickAgain.bind(null, aCallback));
|
||||
}
|
||||
|
||||
clickAgain(function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
clickLink("link-domain", function() {
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
ok(isLoading(), "Should start loading again");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Loading an insecure main page should work if that is what the prefs say, should
|
||||
// also be able to navigate to a https page and back again
|
||||
add_test(function() {
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, TESTROOT + "discovery.html");
|
||||
|
||||
open_manager("addons://discover/", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url");
|
||||
|
||||
clickLink("link-normal", function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
clickLink("link-http", function() {
|
||||
is(getURL(browser), TESTROOT + "discovery.html", "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Stopping the initial load should display the error page and then correctly
|
||||
// reload when switching away and back again
|
||||
add_test(function() {
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
|
||||
EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
EventUtils.synthesizeMouse(gCategoryUtilities.get("discover"), 2, 2, { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
ok(isError(), "Should have shown the error page");
|
||||
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
gCategoryUtilities.openType("discover", function() {
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ok(isLoading(), "Should be loading");
|
||||
// This will stop the real page load
|
||||
browser.stop();
|
||||
});
|
||||
});
|
||||
|
||||
ok(isLoading(), "Should be loading");
|
||||
// This will actually stop the about:blank load
|
||||
browser.stop();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<html>
|
||||
<body>
|
||||
<h1>Test page for the discovery pane</h1>
|
||||
<p><a id="link-normal" href="https://example.com/browser/toolkit/mozapps/extensions/test/browser/discovery.html">Load normal</a></p>
|
||||
<p><a id="link-http" href="http://example.com/browser/toolkit/mozapps/extensions/test/browser/discovery.html">Load insecure</a></p>
|
||||
<p><a id="link-domain" href="https://test1.example.com/browser/toolkit/mozapps/extensions/test/browser/discovery.html">Load other domain</a></p>
|
||||
<p><a id="link-bad" href="https://example.com/browser/toolkit/mozapps/extensions/test/browser/foo.html">Load missing page</a></p>
|
||||
<p><a id="link-good" href="https://example.com/browser/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml">Load other page</a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -81,6 +81,17 @@ registerCleanupFunction(function() {
|
|||
});
|
||||
});
|
||||
|
||||
function log_exceptions(aCallback) {
|
||||
try {
|
||||
var args = Array.slice(arguments, 1);
|
||||
return aCallback.apply(null, args);
|
||||
}
|
||||
catch (e) {
|
||||
info("Exception thrown: " + e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function add_test(test) {
|
||||
gPendingTests.push(test);
|
||||
}
|
||||
|
@ -102,7 +113,7 @@ function run_next_test() {
|
|||
info("Running test " + gTestsRun);
|
||||
|
||||
gTestStart = Date.now();
|
||||
test();
|
||||
log_exceptions(test);
|
||||
}
|
||||
|
||||
function get_addon_file_url(aFilename) {
|
||||
|
@ -193,33 +204,33 @@ function wait_for_view_load(aManagerWindow, aCallback, aForceWait, aLongerTimeou
|
|||
requestLongerTimeout(aLongerTimeout ? aLongerTimeout : 2);
|
||||
|
||||
if (!aForceWait && !aManagerWindow.gViewController.isLoading) {
|
||||
aCallback(aManagerWindow);
|
||||
log_exceptions(aCallback, aManagerWindow);
|
||||
return;
|
||||
}
|
||||
|
||||
aManagerWindow.document.addEventListener("ViewChanged", function() {
|
||||
aManagerWindow.document.removeEventListener("ViewChanged", arguments.callee, false);
|
||||
aCallback(aManagerWindow);
|
||||
log_exceptions(aCallback, aManagerWindow);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function wait_for_manager_load(aManagerWindow, aCallback) {
|
||||
if (!aManagerWindow.gIsInitializing) {
|
||||
aCallback(aManagerWindow);
|
||||
log_exceptions(aCallback, aManagerWindow);
|
||||
return;
|
||||
}
|
||||
|
||||
info("Waiting for initialization");
|
||||
aManagerWindow.document.addEventListener("Initialized", function() {
|
||||
aManagerWindow.document.removeEventListener("Initialized", arguments.callee, false);
|
||||
aCallback(aManagerWindow);
|
||||
log_exceptions(aCallback, aManagerWindow);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function open_manager(aView, aCallback, aLoadCallback, aLongerTimeout) {
|
||||
function setup_manager(aManagerWindow) {
|
||||
if (aLoadCallback)
|
||||
aLoadCallback(aManagerWindow);
|
||||
log_exceptions(aLoadCallback, aManagerWindow);
|
||||
|
||||
if (aView)
|
||||
aManagerWindow.loadView(aView);
|
||||
|
@ -254,7 +265,7 @@ function close_manager(aManagerWindow, aCallback, aLongerTimeout) {
|
|||
|
||||
aManagerWindow.addEventListener("unload", function() {
|
||||
this.removeEventListener("unload", arguments.callee, false);
|
||||
aCallback();
|
||||
log_exceptions(aCallback);
|
||||
}, false);
|
||||
|
||||
aManagerWindow.close();
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 12 KiB |
|
@ -358,6 +358,40 @@
|
|||
}
|
||||
|
||||
|
||||
/*** discover view ***/
|
||||
|
||||
.discover-spacer-before,
|
||||
.discover-spacer-after {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
#discover-error .alert {
|
||||
max-width: 45em;
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.discover-logo {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/discover-logo.png");
|
||||
-moz-margin-end: 15px;
|
||||
}
|
||||
|
||||
.discover-title {
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
font-family: MetaWebPro-Book, "Trebuchet MS", sans-serif;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-description {
|
||||
text-align: justify;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-footer {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
|
||||
/*** list ***/
|
||||
|
||||
.list {
|
||||
|
|
|
@ -13,6 +13,7 @@ toolkit.jar:
|
|||
+ skin/classic/mozapps/extensions/category-plugins.png (extensions/category-plugins.png)
|
||||
+ skin/classic/mozapps/extensions/category-recent.png (extensions/category-recent.png)
|
||||
+ skin/classic/mozapps/extensions/category-available.png (extensions/category-available.png)
|
||||
+ skin/classic/mozapps/extensions/discover-logo.png (extensions/discover-logo.png)
|
||||
+ skin/classic/mozapps/extensions/extensionGeneric.png (extensions/extensionGeneric.png)
|
||||
+ skin/classic/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16.png)
|
||||
+ skin/classic/mozapps/extensions/themeGeneric.png (extensions/themeGeneric.png)
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 12 KiB |
|
@ -175,7 +175,7 @@
|
|||
}
|
||||
|
||||
.loading {
|
||||
list-style-image: url("chrome://global/skin/icons/loading_16.png");
|
||||
list-style-image: url("chrome://global/skin/icons/loading_16.png");
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
@ -388,6 +388,40 @@
|
|||
}
|
||||
|
||||
|
||||
/*** discover view ***/
|
||||
|
||||
.discover-spacer-before,
|
||||
.discover-spacer-after {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
#discover-error .alert {
|
||||
max-width: 45em;
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.discover-logo {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/discover-logo.png");
|
||||
-moz-margin-end: 15px;
|
||||
}
|
||||
|
||||
.discover-title {
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
font-family: MetaWebPro-Book, "Trebuchet MS", sans-serif;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-description {
|
||||
text-align: justify;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-footer {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
|
||||
/*** list ***/
|
||||
|
||||
.list {
|
||||
|
|
|
@ -14,6 +14,7 @@ toolkit.jar:
|
|||
skin/classic/mozapps/extensions/category-plugins.png (extensions/category-plugins.png)
|
||||
skin/classic/mozapps/extensions/category-recent.png (extensions/category-recent.png)
|
||||
skin/classic/mozapps/extensions/category-available.png (extensions/category-available.png)
|
||||
skin/classic/mozapps/extensions/discover-logo.png (extensions/discover-logo.png)
|
||||
skin/classic/mozapps/extensions/extensionGeneric.png (extensions/extensionGeneric.png)
|
||||
skin/classic/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16.png)
|
||||
skin/classic/mozapps/extensions/themeGeneric.png (extensions/themeGeneric.png)
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 12 KiB |
|
@ -445,6 +445,40 @@
|
|||
}
|
||||
|
||||
|
||||
/*** discover view ***/
|
||||
|
||||
.discover-spacer-before,
|
||||
.discover-spacer-after {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
#discover-error .alert {
|
||||
max-width: 45em;
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.discover-logo {
|
||||
list-style-image: url("chrome://mozapps/skin/extensions/discover-logo.png");
|
||||
-moz-margin-end: 15px;
|
||||
}
|
||||
|
||||
.discover-title {
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
font-family: MetaWebPro-Book, "Trebuchet MS", sans-serif;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-description {
|
||||
text-align: justify;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.discover-footer {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
|
||||
/*** list ***/
|
||||
|
||||
.list {
|
||||
|
|
|
@ -21,6 +21,7 @@ toolkit.jar:
|
|||
skin/classic/mozapps/extensions/category-plugins.png (extensions/category-plugins.png)
|
||||
skin/classic/mozapps/extensions/category-recent.png (extensions/category-recent.png)
|
||||
skin/classic/mozapps/extensions/category-available.png (extensions/category-available.png)
|
||||
skin/classic/mozapps/extensions/discover-logo.png (extensions/discover-logo.png)
|
||||
skin/classic/mozapps/extensions/extensionGeneric.png (extensions/extensionGeneric.png)
|
||||
skin/classic/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16.png)
|
||||
skin/classic/mozapps/extensions/themeGeneric.png (extensions/themeGeneric.png)
|
||||
|
@ -96,6 +97,7 @@ toolkit.jar:
|
|||
skin/classic/aero/mozapps/extensions/category-plugins.png (extensions/category-plugins-aero.png)
|
||||
skin/classic/aero/mozapps/extensions/category-recent.png (extensions/category-recent-aero.png)
|
||||
skin/classic/aero/mozapps/extensions/category-available.png (extensions/category-available-aero.png)
|
||||
skin/classic/aero/mozapps/extensions/discover-logo.png (extensions/discover-logo.png)
|
||||
skin/classic/aero/mozapps/extensions/extensionGeneric.png (extensions/extensionGeneric-aero.png)
|
||||
skin/classic/aero/mozapps/extensions/extensionGeneric-16.png (extensions/extensionGeneric-16-aero.png)
|
||||
skin/classic/aero/mozapps/extensions/themeGeneric.png (extensions/themeGeneric-aero.png)
|
||||
|
|
Загрузка…
Ссылка в новой задаче