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 /browser/components/newtab/tests/xpcshell/test_NewTabURL.js | |
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 'browser/components/newtab/tests/xpcshell/test_NewTabURL.js')
-rw-r--r-- | browser/components/newtab/tests/xpcshell/test_NewTabURL.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/browser/components/newtab/tests/xpcshell/test_NewTabURL.js b/browser/components/newtab/tests/xpcshell/test_NewTabURL.js new file mode 100644 index 000000000..1505e638c --- /dev/null +++ b/browser/components/newtab/tests/xpcshell/test_NewTabURL.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* globals Services, NewTabURL, XPCOMUtils, aboutNewTabService, NewTabPrefsProvider */ +"use strict"; + +const {utils: Cu} = Components; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource:///modules/NewTabURL.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "NewTabPrefsProvider", + "resource:///modules/NewTabPrefsProvider.jsm"); +XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", + "@mozilla.org/browser/aboutnewtab-service;1", + "nsIAboutNewTabService"); + +add_task(function*() { + let defaultURL = aboutNewTabService.newTabURL; + Services.prefs.setBoolPref("browser.newtabpage.remote", false); + + Assert.equal(NewTabURL.get(), defaultURL, `Default newtab URL should be ${defaultURL}`); + let url = "http://example.com/"; + let notificationPromise = promiseNewtabURLNotification(url); + NewTabURL.override(url); + yield notificationPromise; + Assert.ok(NewTabURL.overridden, "Newtab URL should be overridden"); + Assert.equal(NewTabURL.get(), url, "Newtab URL should be the custom URL"); + + notificationPromise = promiseNewtabURLNotification(defaultURL); + NewTabURL.reset(); + yield notificationPromise; + Assert.ok(!NewTabURL.overridden, "Newtab URL should not be overridden"); + Assert.equal(NewTabURL.get(), defaultURL, "Newtab URL should be the default"); + + // change newtab page to remote + NewTabPrefsProvider.prefs.init(); + Services.prefs.setBoolPref("browser.newtabpage.remote", true); + Assert.equal(NewTabURL.get(), "about:newtab", `Newtab URL should be about:newtab`); + Assert.ok(!NewTabURL.overridden, "Newtab URL should not be overridden"); + NewTabPrefsProvider.prefs.uninit(); +}); + +function promiseNewtabURLNotification(aNewURL) { + return new Promise(resolve => { + Services.obs.addObserver(function observer(aSubject, aTopic, aData) { // jshint ignore:line + Services.obs.removeObserver(observer, aTopic); + Assert.equal(aData, aNewURL, "Data for newtab-url-changed notification should be new URL."); + resolve(); + }, "newtab-url-changed", false); + }); +} |