Skip to content

Commit

Permalink
Merge m-c to inbound, a=merge
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: EMipuOLERUq
  • Loading branch information
KWierso committed Jan 18, 2017
2 parents 2038086 + 54c460d commit 95949a3
Show file tree
Hide file tree
Showing 350 changed files with 8,169 additions and 3,783 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ devtools/client/responsivedesign/**
devtools/client/scratchpad/**
devtools/client/shadereditor/**
devtools/client/shared/*.jsm
devtools/client/shared/components/reps/reps.js
devtools/client/shared/webgl-utils.js
devtools/client/shared/widgets/*.jsm
devtools/client/webaudioeditor/**
Expand Down
25 changes: 24 additions & 1 deletion browser/base/content/test/urlbar/browser_dragdropURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

const TEST_URL = "data:text/html,a test page";
const DRAG_URL = "http://www.example.com/";
const DRAG_FORBIDDEN_URL = "chrome://browser/content/aboutDialog.xul";
const DRAG_TEXT = "Firefox is awesome";
const DRAG_WORD = "Firefox";

add_task(function* checkURLBarUpdateForDrag() {
add_task(function* checkDragURL() {
yield BrowserTestUtils.withNewTab(TEST_URL, function* (browser) {
// Have to use something other than the URL bar as a source, so picking the
// downloads button somewhat arbitrarily:
Expand All @@ -13,3 +16,23 @@ add_task(function* checkURLBarUpdateForDrag() {
is(gBrowser.selectedBrowser.userTypedValue, null, "Stored URL bar value should not have changed");
});
});

add_task(function* checkDragForbiddenURL() {
yield BrowserTestUtils.withNewTab(TEST_URL, function* (browser) {
EventUtils.synthesizeDrop(document.getElementById("downloads-button"), gURLBar,
[[{type: "text/plain", data: DRAG_FORBIDDEN_URL}]], "copy", window);
isnot(gURLBar.value, DRAG_FORBIDDEN_URL, "Shouldn't be allowed to drop forbidden URL on URL bar");
});
});

add_task(function* checkDragText() {
yield BrowserTestUtils.withNewTab(TEST_URL, function* (browser) {
EventUtils.synthesizeDrop(document.getElementById("downloads-button"), gURLBar,
[[{type: "text/plain", data: DRAG_TEXT}]], "copy", window);
is(gURLBar.value, DRAG_TEXT, "Dragging normal text should replace the URL bar value");

EventUtils.synthesizeDrop(document.getElementById("downloads-button"), gURLBar,
[[{type: "text/plain", data: DRAG_WORD}]], "copy", window);
is(gURLBar.value, DRAG_WORD, "Dragging a single word should replace the URL bar value");
});
});
60 changes: 43 additions & 17 deletions browser/base/content/urlbarBindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,23 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]></body>
</method>

<method name="_getDroppableLink">
<!-- Returns:
null if there's a security issue and we should do nothing.
a URL object if there is one that we're OK with loading,
a text value otherwise.
-->
<method name="_getDroppableItem">
<parameter name="aEvent"/>
<body><![CDATA[
let links = browserDragAndDrop.dropLinks(aEvent);
let links;
try {
links = browserDragAndDrop.dropLinks(aEvent);
} catch (ex) {
// this is possibly a security exception, in which case we should return
// null. Always return null because we can't *know* what exception is
// being returned.
return null;
}
// The URL bar automatically handles inputs with newline characters,
// so we can get away with treating text/x-moz-url flavours as text/plain.
if (links.length > 0 && links[0].url) {
Expand All @@ -715,24 +728,35 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
aEvent.stopImmediatePropagation();
return null;
}
let urlObj;
try {
urlSecurityCheck(url,
gBrowser.contentPrincipal,
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
// If this throws, urlSecurityCheck would also throw, as that's what it
// does with things that don't pass the IO service's newURI constructor
// without fixup. It's conceivable we may want to relax this check in
// the future (so e.g. www.foo.com gets fixed up), but not right now.
urlObj = new URL(url);
// If we succeed, try to pass security checks. If this works, return the
// URL object. If the *security checks* fail, return null.
try {
urlSecurityCheck(url,
gBrowser.contentPrincipal,
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
return urlObj;
} catch (ex) {
return null;
}
} catch (ex) {
return null;
// We couldn't make a URL out of this. Continue on, and return text below.
}
return url;
}
return null;
return aEvent.dataTransfer.getData("text/unicode");
]]></body>
</method>

<method name="onDragOver">
<parameter name="aEvent"/>
<body><![CDATA[
// We don't need the link here, so we ignore the return value.
if (!this._getDroppableLink(aEvent)) {
if (!this._getDroppableItem(aEvent)) {
aEvent.dataTransfer.dropEffect = "none";
}
]]></body>
Expand All @@ -741,15 +765,17 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<method name="onDrop">
<parameter name="aEvent"/>
<body><![CDATA[
let url = this._getDroppableLink(aEvent);
if (url) {
this.value = url;
let droppedItem = this._getDroppableItem(aEvent);
if (droppedItem) {
this.value = droppedItem instanceof URL ? droppedItem.href : droppedItem;
SetPageProxyState("invalid");
this.focus();
this.handleCommand();
// Force not showing the dropped URI immediately.
gBrowser.userTypedValue = null;
URLBarSetURI();
if (droppedItem instanceof URL) {
this.handleCommand();
// Force not showing the dropped URI immediately.
gBrowser.userTypedValue = null;
URLBarSetURI();
}
}
]]></body>
</method>
Expand Down
35 changes: 24 additions & 11 deletions browser/components/migration/AutoMigrate.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,14 @@ const AutoMigrate = {
return profiles ? profiles[0] : null;
},

_pendingUndoTasks: false,
canUndo: Task.async(function* () {
if (this._savingPromise) {
yield this._savingPromise;
}
if (this._pendingUndoTasks) {
return false;
}
let fileExists = false;
try {
fileExists = yield OS.File.exists(kUndoStateFullPath);
Expand All @@ -197,6 +201,8 @@ const AutoMigrate = {
throw new Error("Can't undo!");
}

this._pendingUndoTasks = true;
this._removeNotificationBars();
histogram.add(10);

let readPromise = OS.File.read(kUndoStateFullPath, {
Expand All @@ -218,18 +224,11 @@ const AutoMigrate = {
NewTabUtils.allPages.update();
}, true);

this.removeUndoOption(this.UNDO_REMOVED_REASON_UNDO_USED);
this._purgeUndoState(this.UNDO_REMOVED_REASON_UNDO_USED);
histogram.add(30);
}),

removeUndoOption(reason) {
// We don't wait for the off-main-thread removal to complete. OS.File will
// ensure it happens before shutdown.
OS.File.remove(kUndoStateFullPath, {ignoreAbsent: true});

let migrationBrowser = Preferences.get(kAutoMigrateBrowserPref, "unknown");
Services.prefs.clearUserPref(kAutoMigrateBrowserPref);

_removeNotificationBars() {
let browserWindows = Services.wm.getEnumerator("navigator:browser");
while (browserWindows.hasMoreElements()) {
let win = browserWindows.getNext();
Expand All @@ -243,6 +242,18 @@ const AutoMigrate = {
}
}
}
},

_purgeUndoState(reason) {
// We don't wait for the off-main-thread removal to complete. OS.File will
// ensure it happens before shutdown.
OS.File.remove(kUndoStateFullPath, {ignoreAbsent: true}).then(() => {
this._pendingUndoTasks = false;
});

let migrationBrowser = Preferences.get(kAutoMigrateBrowserPref, "unknown");
Services.prefs.clearUserPref(kAutoMigrateBrowserPref);

let histogram =
Services.telemetry.getKeyedHistogramById("FX_STARTUP_MIGRATION_UNDO_REASON");
histogram.add(migrationBrowser, reason);
Expand Down Expand Up @@ -278,7 +289,8 @@ const AutoMigrate = {
// in which case we remove the undo prefs (which will cause canUndo() to
// return false from now on.):
if (!this.shouldStillShowUndoPrompt()) {
this.removeUndoOption(this.UNDO_REMOVED_REASON_OFFER_EXPIRED);
this._purgeUndoState(this.UNDO_REMOVED_REASON_OFFER_EXPIRED);
this._removeNotificationBars();
return;
}

Expand All @@ -296,7 +308,8 @@ const AutoMigrate = {
label: MigrationUtils.getLocalizedString("automigration.undo.keep.label"),
accessKey: MigrationUtils.getLocalizedString("automigration.undo.keep.accesskey"),
callback: () => {
this.removeUndoOption(this.UNDO_REMOVED_REASON_OFFER_REJECTED);
this._purgeUndoState(this.UNDO_REMOVED_REASON_OFFER_REJECTED);
this._removeNotificationBars();
},
},
{
Expand Down
1 change: 1 addition & 0 deletions browser/components/migration/tests/browser/browser.ini
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[browser_undo_notification.js]
[browser_undo_notification_multiple_dismissal.js]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ Cu.import("resource:///modules/AutoMigrate.jsm", scope);
let oldCanUndo = scope.AutoMigrate.canUndo;
let oldUndo = scope.AutoMigrate.undo;
registerCleanupFunction(function() {
Cu.reportError("Cleaning up");
scope.AutoMigrate.canUndo = oldCanUndo;
scope.AutoMigrate.undo = oldUndo;
Cu.reportError("Cleaned up");
});

const kExpectedNotificationId = "automigration-undo";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"use strict";


const kExpectedNotificationId = "automigration-undo";

/**
* Pretend we can undo something, trigger a notification, pick the undo option,
* and verify that the notifications are all dismissed immediately.
*/
add_task(function* checkNotificationsDismissed() {
yield SpecialPowers.pushPrefEnv({set: [
["browser.migrate.automigrate.enabled", true],
["browser.migrate.automigrate.ui.enabled", true],
]});
let getNotification = browser =>
gBrowser.getNotificationBox(browser).getNotificationWithValue(kExpectedNotificationId);

Services.prefs.setCharPref("browser.migrate.automigrate.browser", "someunknownbrowser");

let {guid, lastModified} = yield PlacesUtils.bookmarks.insert(
{title: "Some imported bookmark", parentGuid: PlacesUtils.bookmarks.toolbarGuid, url: "http://www.example.com"}
);

let testUndoData = {
visits: [],
bookmarks: [{guid, lastModified: lastModified.getTime()}],
logins: [],
};
let path = OS.Path.join(OS.Constants.Path.profileDir, "initialMigrationMetadata.jsonlz4");
registerCleanupFunction(() => {
return OS.File.remove(path, {ignoreAbsent: true});
});
yield OS.File.writeAtomic(path, JSON.stringify(testUndoData), {
encoding: "utf-8",
compression: "lz4",
tmpPath: path + ".tmp",
});

let firstTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home", false);
if (!getNotification(firstTab.linkedBrowser)) {
info(`Notification not immediately present on first tab, waiting for it.`);
yield BrowserTestUtils.waitForNotificationBar(gBrowser, firstTab.linkedBrowser, kExpectedNotificationId);
}
let secondTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home", false);
if (!getNotification(secondTab.linkedBrowser)) {
info(`Notification not immediately present on second tab, waiting for it.`);
yield BrowserTestUtils.waitForNotificationBar(gBrowser, secondTab.linkedBrowser, kExpectedNotificationId);
}

// Create a listener for the removal in the first tab, and a listener for bookmarks removal,
// then click 'Don't keep' in the second tab, and verify that the notification is removed
// before we start removing bookmarks.
let haveRemovedBookmark = false;
let bmObserver;
let bookmarkRemovedPromise = new Promise(resolve => {
bmObserver = {
onItemRemoved(itemId, parentId, index, itemType, uri, removedGuid) {
if (guid == removedGuid) {
haveRemovedBookmark = true;
resolve();
}
},
};
PlacesUtils.bookmarks.addObserver(bmObserver, false);
registerCleanupFunction(() => PlacesUtils.bookmarks.removeObserver(bmObserver));
});

let firstTabNotificationRemovedPromise = new Promise(resolve => {
let notification = getNotification(firstTab.linkedBrowser);
// Save this reference because notification.parentNode will be null once it's removed.
let notificationBox = notification.parentNode;
let mut = new MutationObserver(mutations => {
// Yucky, but we have to detect either the removal via animation (with marginTop)
// or when the element is removed. We can't just detect the element being removed
// because this happens asynchronously (after the animation) and so it'd race
// with the rest of the undo happening.
for (let mutation of mutations) {
if (mutation.target == notification && mutation.attributeName == "style" &&
parseInt(notification.style.marginTop, 10) < 0) {
ok(!haveRemovedBookmark, "Should not have removed bookmark yet");
mut.disconnect();
resolve();
return;
}
if (mutation.target == notificationBox && mutation.removedNodes.length &&
mutation.removedNodes[0] == notification) {
ok(!haveRemovedBookmark, "Should not have removed bookmark yet");
mut.disconnect();
resolve();
return;
}
}
});
mut.observe(notification.parentNode, {childList: true});
mut.observe(notification, {attributes: true});
});

let prefResetPromise = new Promise(resolve => {
const kObservedPref = "browser.migrate.automigrate.browser";
let obs = () => {
Services.prefs.removeObserver(kObservedPref, obs);
ok(!Services.prefs.prefHasUserValue(kObservedPref),
"Pref should have been reset");
resolve();
};
Services.prefs.addObserver(kObservedPref, obs, false);
});

// Click "Don't keep" button:
let notificationToActivate = getNotification(secondTab.linkedBrowser);
notificationToActivate.querySelector("button:not(.notification-button-default)").click();
info("Waiting for notification to be removed in first (background) tab");
yield firstTabNotificationRemovedPromise;
info("Waiting for bookmark to be removed");
yield bookmarkRemovedPromise;
info("Waiting for prefs to be reset");
yield prefResetPromise;

info("Removing spare tabs");
yield BrowserTestUtils.removeTab(firstTab);
yield BrowserTestUtils.removeTab(secondTab);
});
3 changes: 3 additions & 0 deletions browser/components/preferences/in-content/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ var gAdvancedPane = {
gAdvancedPane.clearSiteData);
setEventListener("siteDataSettings", "command",
gAdvancedPane.showSiteDataSettings);

let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "storage-permissions";
document.getElementById("siteDataLearnMoreLink").setAttribute("href", url);
}

setEventListener("layers.acceleration.disabled", "change",
Expand Down
4 changes: 3 additions & 1 deletion browser/components/preferences/in-content/advanced.xul
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@
<caption><label>&siteData.label;</label></caption>

<hbox align="center">
<label id="totalSiteDataSize" flex="1"></label>
<label id="totalSiteDataSize"></label>
<label id="siteDataLearnMoreLink" class="learnMore text-link" value="&siteDataLearnMoreLink.label;"></label>
<spacer flex="1" />
<button id="clearSiteDataButton" icon="clear"
label="&clearSiteData.label;" accesskey="&clearSiteData.accesskey;"/>
</hbox>
Expand Down
4 changes: 4 additions & 0 deletions browser/extensions/mortar/host/pdf/chrome/js/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class Toolbar {
case 'pageRotateCcw':
this._viewport.rotateCounterClockwise();
break;
case 'presentationMode':
case 'secondaryPresentationMode':
this._viewport.fullscreen = true;
break;
case 'secondaryToolbarToggle':
this._secondaryToolbar.toggle();
break;
Expand Down
Loading

0 comments on commit 95949a3

Please sign in to comment.