Merge inbound to mozilla-central. a=merge

This commit is contained in:
shindli 2018-11-23 11:38:42 +02:00
commit 20df68a5f5
13 changed files with 155 additions and 3 deletions

View File

@ -5,14 +5,17 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Preferences.jsm");
let gDefaultBranch = Services.prefs.getDefaultBranch("");
let gPrefArray;
function onLoad() {
gPrefArray = Services.prefs.getChildList("").map(function(name) {
let hasUserValue = Services.prefs.prefHasUserValue(name);
let pref = {
name,
value: Preferences.get(name),
hasUserValue: Services.prefs.prefHasUserValue(name),
hasUserValue,
hasDefaultValue: hasUserValue ? prefHasDefaultValue(name) : true,
};
// Try in case it's a localized string.
// Throws an exception if there is no equivalent value in the localized files for the pref.
@ -36,6 +39,16 @@ function onLoad() {
});
document.getElementById("prefs").appendChild(createPrefsFragment(gPrefArray));
document.getElementById("prefs").addEventListener("click", (event) => {
if (event.target.localName != "button") {
return;
}
let prefRow = event.target.closest("tr");
let prefName = prefRow.getAttribute("aria-label");
Services.prefs.clearUserPref(prefName);
gPrefArray.splice(gPrefArray.findIndex(pref => pref.name == prefName), 1);
prefRow.remove();
});
}
function filterPrefs() {
@ -68,7 +81,32 @@ function createPrefsFragment(prefArray) {
valueCell.textContent = pref.value;
row.appendChild(valueCell);
let buttonCell = document.createElement("td");
if (!pref.hasDefaultValue) {
let button = document.createElement("button");
document.l10n.setAttributes(button, "about-config-pref-delete");
buttonCell.appendChild(button);
}
row.appendChild(buttonCell);
fragment.appendChild(row);
}
return fragment;
}
function prefHasDefaultValue(name) {
try {
switch (Services.prefs.getPrefType(name)) {
case Ci.nsIPrefBranch.PREF_STRING:
gDefaultBranch.getStringPref(name);
return true;
case Ci.nsIPrefBranch.PREF_INT:
gDefaultBranch.getIntPref(name);
return true;
case Ci.nsIPrefBranch.PREF_BOOL:
gDefaultBranch.getBoolPref(name);
return true;
}
} catch (ex) {}
return false;
}

View File

@ -4,5 +4,7 @@
about-config-title = about:config
about-config-pref-delete = Delete
about-config-search =
.placeholder = Search

View File

@ -1,5 +1,6 @@
[DEFAULT]
[browser_basic.js]
[browser_edit.js]
[browser_search.js]
skip-if = debug # Bug 1507747

View File

@ -0,0 +1,26 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const PAGE_URL = "chrome://browser/content/aboutconfig/aboutconfig.html";
add_task(async function test_delete_user_pref() {
Services.prefs.setBoolPref("userAddedPref", true);
await BrowserTestUtils.withNewTab({
gBrowser,
url: PAGE_URL,
}, browser => {
return ContentTask.spawn(browser, null, () => {
let list = [...content.document.getElementById("prefs")
.getElementsByTagName("tr")];
function getRow(name) {
return list.find(row => row.querySelector("td").textContent == name);
}
Assert.ok(getRow("userAddedPref"));
getRow("userAddedPref").lastChild.lastChild.click();
list = [...content.document.getElementById("prefs")
.getElementsByTagName("tr")];
Assert.ok(!getRow("userAddedPref"));
Assert.ok(!Services.prefs.getChildList("").includes("userAddedPref"));
});
});
});

View File

@ -10269,6 +10269,23 @@ nsDocShell::DoURILoad(nsIURI* aURI,
}
if (IsFrame()) {
bool doesNotReturnData = false;
NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
&doesNotReturnData);
if (doesNotReturnData) {
// If this is an iframe, it must have a parent. Let's count the
// no-data-URL telemetry on the parent document, because probably this one
// is an about page.
nsCOMPtr<nsIDocShellTreeItem> parent;
GetSameTypeParent(getter_AddRefs(parent));
MOZ_ASSERT(parent);
nsIDocument* parentDocument = parent->GetDocument();
if (parentDocument) {
parentDocument->SetDocumentAndPageUseCounter(eUseCounter_custom_no_data_URL);
}
}
MOZ_ASSERT(aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME ||
aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME,

View File

@ -60,6 +60,9 @@ attribute Window.sidebar
// External interface
method External.AddSearchProvider
// no-data URLs for iframes
custom no_data_URL used in iframes
// AppCache API
method OfflineResourceList.swapCache
method OfflineResourceList.update

View File

@ -7986,6 +7986,25 @@ nsGlobalWindowInner::ForgetSharedWorker(SharedWorker* aSharedWorker)
mSharedWorkers.RemoveElement(aSharedWorker);
}
void
nsGlobalWindowInner::StorageAccessGranted()
{
// If we have a partitioned localStorage, it's time to replace it with a real
// one in order to receive notifications.
if (mLocalStorage &&
mLocalStorage->Type() == Storage::ePartitionedLocalStorage) {
IgnoredErrorResult error;
GetLocalStorage(error);
if (NS_WARN_IF(error.Failed())) {
return;
}
MOZ_ASSERT(mLocalStorage &&
mLocalStorage->Type() == Storage::eLocalStorage);
}
}
mozilla::dom::TabGroup*
nsPIDOMWindowInner::TabGroup()
{

View File

@ -1241,6 +1241,11 @@ public:
// area.
nsIPrincipal* GetTopLevelStorageAreaPrincipal();
// This method is called if this window loads a 3rd party tracking resource
// and the storage is just been granted. The window can reset the partitioned
// storage objects and switch to the first party cookie jar.
void StorageAccessGranted();
protected:
static void NotifyDOMWindowDestroyed(nsGlobalWindowInner* aWindow);
void NotifyWindowIDDestroyed(const char* aTopic);

View File

@ -29,6 +29,8 @@ this.EXPORTED_SYMBOLS = ["assert"];
const isFennec = () => AppConstants.platform == "android";
const isFirefox = () =>
Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
const isThunderbird = () =>
Services.appinfo.ID == "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
/**
* Shorthands for common assertions made in Marionette.
@ -91,6 +93,21 @@ assert.firefox = function(msg = "") {
assert.that(isFirefox, msg, UnsupportedOperationError)();
};
/**
* Asserts that the current browser is Firefox Desktop or Thunderbird.
*
* @param {string=} msg
* Custom error message.
*
* @throws {UnsupportedOperationError}
* If current browser is not Firefox or Thunderbird.
*/
assert.desktop = function(msg = "") {
msg = msg || "Only supported in desktop applications";
assert.that(obj => isFirefox(obj) || isThunderbird(obj),
msg, UnsupportedOperationError)();
};
/**
* Asserts that the current browser is Fennec, or Firefox for Android.
*

View File

@ -98,6 +98,10 @@ browser.getTabBrowser = function(window) {
// Firefox
} else if ("gBrowser" in window) {
return window.gBrowser;
// Thunderbird
} else if (window.document.getElementById("tabmail")) {
return window.document.getElementById("tabmail");
}
return null;

View File

@ -324,6 +324,7 @@ class MarionetteParentProcess {
case "profile-after-change":
Services.obs.addObserver(this, "command-line-startup");
Services.obs.addObserver(this, "sessionstore-windows-restored");
Services.obs.addObserver(this, "mail-startup-done");
Services.obs.addObserver(this, "toplevel-window-ready");
for (let [pref, value] of EnvironmentPrefs.from(ENV_PRESERVE_PREFS)) {
@ -378,6 +379,12 @@ class MarionetteParentProcess {
}, {once: true});
break;
// Thunderbird only, instead of sessionstore-windows-restored.
case "mail-startup-done":
this.finalUIStartup = true;
this.init();
break;
case "sessionstore-windows-restored":
Services.obs.removeObserver(this, topic);
Services.obs.removeObserver(this, "toplevel-window-ready");

View File

@ -70,6 +70,7 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
this.EXPORTED_SYMBOLS = ["GeckoDriver"];
const APP_ID_FIREFOX = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
const APP_ID_THUNDERBIRD = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
const FRAME_SCRIPT = "chrome://marionette/content/listener.js";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -718,7 +719,16 @@ GeckoDriver.prototype.newSession = async function(cmd) {
let browserListening = this.listeningPromise();
let waitForWindow = function() {
let win = Services.wm.getMostRecentWindow("navigator:browser");
let windowType;
switch (this.appId) {
case APP_ID_THUNDERBIRD:
windowType = "mail:3pane";
break;
default:
windowType = "navigator:browser";
break;
}
let win = Services.wm.getMostRecentWindow(windowType);
if (!win) {
// if the window isn't even created, just poll wait for it
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
@ -3303,7 +3313,7 @@ GeckoDriver.prototype.quit = async function(cmd) {
};
GeckoDriver.prototype.installAddon = function(cmd) {
assert.firefox();
assert.desktop();
let path = cmd.parameters.path;
let temp = cmd.parameters.temporary || false;

View File

@ -536,6 +536,9 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(nsIPrincipal* aPrincipa
// Let's store the permission in the current parent window.
topInnerWindow->SaveStorageAccessGranted(permissionKey);
// Let's inform the parent window.
parentWindow->StorageAccessGranted();
nsIChannel* channel =
pwin->GetCurrentInnerWindow()->GetExtantDoc()->GetChannel();