author | Felipe Gomes <felipc@gmail.com> |
Fri, 16 Mar 2018 21:02:05 -0300 | |
changeset 462190 | 92e35648ab76fedfcc9a7a3a4524c266c8501d86 |
parent 462189 | 6b82b05b0d38bb5343a1732385bd3ddaed4b52e5 |
child 462191 | 6663b286d68c09979af181f3ca9d779c89b271f2 |
push id | 9165 |
push user | asasaki@mozilla.com |
push date | Thu, 26 Apr 2018 21:04:54 +0000 |
treeherder | mozilla-beta@064c3804de2e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mak |
bugs | 1439443 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -306,16 +306,24 @@ var Policies = { }, "InstallAddons": { onBeforeUIStartup(manager, param) { addAllowDenyPermissions("install", param.Allow, null); } }, + "NoDefaultBookmarks": { + onProfileAfterChange(manager, param) { + if (param) { + manager.disallowFeature("defaultBookmarks"); + } + } + }, + "Popups": { onBeforeUIStartup(manager, param) { addAllowDenyPermissions("popup", param.Allow, null); } }, "RememberPasswords": { onBeforeUIStartup(manager, param) {
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json +++ b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -278,16 +278,24 @@ "type": "array", "items": { "type": "origin" } } } }, + "NoDefaultBookmarks": { + "description": "Don't create the default bookmarks bundled with Firefox, nor the Smart Bookmarks (Most Visited, Recent Tags). Note: this policy is only effective if used before the first run of the profile.", + "first_available": "60.0", + + "type": "boolean", + "enum": [true] + }, + "Popups": { "description": "Allow or deny popup usage.", "first_available": "60.0", "type": "object", "properties": { "Allow": { "type": "array",
new file mode 100644 --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/disable_default_bookmarks/bookmarks_policies.json @@ -0,0 +1,5 @@ +{ + "policies": { + "NoDefaultBookmarks": true + } +}
copy from browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser.ini copy to browser/components/enterprisepolicies/tests/browser/disable_default_bookmarks/browser.ini --- a/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/browser.ini +++ b/browser/components/enterprisepolicies/tests/browser/disable_default_bookmarks/browser.ini @@ -1,8 +1,8 @@ [DEFAULT] prefs = browser.policies.enabled=true - browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/config_disable_developer_tools.json' + browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/disable_default_bookmarks/bookmarks_policies.json' support-files = - config_disable_developer_tools.json + bookmarks_policies.json -[browser_policy_disable_developer_tools.js] +[browser_policy_no_default_bookmarks.js]
new file mode 100644 --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/disable_default_bookmarks/browser_policy_no_default_bookmarks.js @@ -0,0 +1,20 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// This test must run in a separate folder because the +// No Default Bookmarks policy needs to be present on +// the first run of the profile, and not dinamically loaded +// like most of the policies tested in the main test folder. + +add_task(async function test_no_default_bookmarks() { + let firstBookmarkOnToolbar = + await PlacesUtils.bookmarks.fetch({parentGuid: PlacesUtils.bookmarks.toolbarGuid, index: 0}); + + let firstBookmarkOnMenu = + await PlacesUtils.bookmarks.fetch({parentGuid: PlacesUtils.bookmarks.menuGuid, index: 0}); + + is(firstBookmarkOnToolbar, null, "No bookmarks on toolbar"); + is(firstBookmarkOnMenu, null, "No bookmarks on menu"); +});
--- a/browser/components/enterprisepolicies/tests/moz.build +++ b/browser/components/enterprisepolicies/tests/moz.build @@ -5,14 +5,15 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. with Files("**"): BUG_COMPONENT = ("Firefox", "General") BROWSER_CHROME_MANIFESTS += [ 'browser/browser.ini', 'browser/disable_app_update/browser.ini', + 'browser/disable_default_bookmarks/browser.ini', 'browser/disable_developer_tools/browser.ini', ] TESTING_JS_MODULES += [ 'EnterprisePolicyTesting.jsm', ]
--- a/browser/components/migration/MigrationUtils.jsm +++ b/browser/components/migration/MigrationUtils.jsm @@ -355,17 +355,18 @@ var MigratorPrototype = { } await completeDeferred.promise; await unblockMainThread(); } } }; - if (MigrationUtils.isStartupMigration && !this.startupOnlyMigrator) { + if (MigrationUtils.isStartupMigration && !this.startupOnlyMigrator && + Services.policies.isAllowed("defaultBookmarks")) { MigrationUtils.profileStartup.doStartup(); // First import the default bookmarks. // Note: We do not need to do so for the Firefox migrator // (=startupOnlyMigrator), as it just copies over the places database // from another profile. (async function() { // Tell nsBrowserGlue we're importing default bookmarks. let browserGlue = Cc["@mozilla.org/browser/browserglue;1"].
--- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -1647,20 +1647,22 @@ BrowserGlue.prototype = { bookmarksUrl = "chrome://browser/locale/bookmarks.html"; } else if (await OS.File.exists(BookmarkHTMLUtils.defaultPath)) { bookmarksUrl = OS.Path.toFileURI(BookmarkHTMLUtils.defaultPath); } if (bookmarksUrl) { // Import from bookmarks.html file. try { - await BookmarkHTMLUtils.importFromURL(bookmarksUrl, { - replace: true, - source: PlacesUtils.bookmarks.SOURCES.RESTORE_ON_STARTUP, - }); + if (Services.policies.isAllowed("defaultBookmarks")) { + await BookmarkHTMLUtils.importFromURL(bookmarksUrl, { + replace: true, + source: PlacesUtils.bookmarks.SOURCES.RESTORE_ON_STARTUP, + }); + } } catch (e) { Cu.reportError("Bookmarks.html file could be corrupt. " + e); } try { // Now apply distribution customized bookmarks. // This should always run after Places initialization. await this._distributionCustomizer.applyBookmarks(); // Ensure that smart bookmarks are created once the operation is @@ -2304,16 +2306,17 @@ BrowserGlue.prototype = { // TODO bug 399268: should this be a pref? const MAX_RESULTS = 10; // Get current smart bookmarks version. If not set, create them. let smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF, 0); // If version is current, or smart bookmarks are disabled, bail out. if (smartBookmarksCurrentVersion == -1 || + !Services.policies.isAllowed("defaultBookmarks") || smartBookmarksCurrentVersion >= SMART_BOOKMARKS_VERSION) { return; } try { let menuIndex = 0; let toolbarIndex = 0; let bundle = Services.strings.createBundle("chrome://browser/locale/places/places.properties");