Skip to content

Commit

Permalink
Merge m-c to inbound, a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
KWierso committed Sep 16, 2016
2 parents 029140f + 2d34ce9 commit 0677d5d
Show file tree
Hide file tree
Showing 50 changed files with 1,514 additions and 243 deletions.
8 changes: 7 additions & 1 deletion browser/base/content/browser-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,18 @@ let gDecoderDoctorHandler = {
if (AppConstants.isPlatformAndVersionAtMost("win", "5.9")) {
return gNavigatorBundle.getString("decoder.noCodecsXP.message");
}
if (!AppConstants.isPlatformAndVersionAtLeast("win", "6.1")) {
return gNavigatorBundle.getString("decoder.noCodecsVista.message");
}
return gNavigatorBundle.getString("decoder.noCodecs.message");
}
if (type == "platform-decoder-not-found") {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6")) {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.1")) {
return gNavigatorBundle.getString("decoder.noHWAcceleration.message");
}
if (AppConstants.isPlatformAndVersionAtLeast("win", "6")) {
return gNavigatorBundle.getString("decoder.noHWAccelerationVista.message");
}
if (AppConstants.platform == "linux") {
return gNavigatorBundle.getString("decoder.noCodecsLinux.message");
}
Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ tabbrowser {
max-width: 210px;
min-width: 100px;
width: 0;
transition: min-width 200ms ease-out,
max-width 230ms ease-out;
transition: min-width 100ms ease-out,
max-width 100ms ease-out;
}

.tabbrowser-tab:not([pinned]):not([fadein]) {
Expand Down
87 changes: 77 additions & 10 deletions browser/base/content/test/urlbar/browser_autocomplete_enter_race.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,90 @@
add_task(function*() {
registerCleanupFunction(function* () {
yield PlacesUtils.bookmarks.remove(bm);
});
// The order of these tests matters!

add_task(function* setup () {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser);
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/?q=%s",
title: "test" });
registerCleanupFunction(function* () {
yield PlacesUtils.bookmarks.remove(bm);
yield BrowserTestUtils.removeTab(tab);
});
yield PlacesUtils.keywords.insert({ keyword: "keyword",
url: "http://example.com/?q=%s" });
// Needs at least one success.
ok(true, "Setup complete");
});

yield new Promise(resolve => waitForFocus(resolve, window));

add_task(function* test_keyword() {
yield promiseAutocompleteResultPopup("keyword bear");
gURLBar.focus();
EventUtils.synthesizeKey("d", {});
EventUtils.synthesizeKey("VK_RETURN", {});
info("wait for the page to load");
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser,
false, "http://example.com/?q=beard");
});

add_task(function* test_sametext() {
yield promiseAutocompleteResultPopup("example.com", window, true);

// Simulate re-entering the same text searched the last time. This may happen
// through a copy paste, but clipboard handling is not much reliable, so just
// fire an input event.
info("synthesize input event");
let event = document.createEvent("Events");
event.initEvent("input", true, true);
gURLBar.dispatchEvent(event);
EventUtils.synthesizeKey("VK_RETURN", {});

info("wait for the page to load");
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser,
false, "http://example.com/");
});

add_task(function* test_after_empty_search() {
yield promiseAutocompleteResultPopup("");
gURLBar.focus();
gURLBar.value = "e";
EventUtils.synthesizeKey("x", {});
EventUtils.synthesizeKey("VK_RETURN", {});

info("wait for the page to load");
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser,
false, "http://example.com/");
});

add_task(function* test_disabled_ac() {
// Disable autocomplete.
let suggestHistory = Preferences.get("browser.urlbar.suggest.history");
Preferences.set("browser.urlbar.suggest.history", false);
let suggestBookmarks = Preferences.get("browser.urlbar.suggest.bookmark");
Preferences.set("browser.urlbar.suggest.bookmark", false);
let suggestOpenPages = Preferences.get("browser.urlbar.suggest.openpage");
Preferences.set("browser.urlbar.suggest.openpages", false);

Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
"http://example.com/?q={searchTerms}");
let engine = Services.search.getEngineByName("MozSearch");
let originalEngine = Services.search.currentEngine;
Services.search.currentEngine = engine;

registerCleanupFunction(function* () {
Preferences.set("browser.urlbar.suggest.history", suggestHistory);
Preferences.set("browser.urlbar.suggest.bookmark", suggestBookmarks);
Preferences.set("browser.urlbar.suggest.openpage", suggestOpenPages);

Services.search.currentEngine = originalEngine;
let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine);
});

gURLBar.focus();
gURLBar.value = "e";
EventUtils.synthesizeKey("x", {});
EventUtils.synthesizeKey("VK_RETURN", {});

yield promiseTabLoadEvent(gBrowser.selectedTab);
is(gBrowser.selectedBrowser.currentURI.spec,
"http://example.com/?q=beard",
"Latest typed characters should have been used");
info("wait for the page to load");
yield BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser,
false, "http://example.com/?q=ex");
});
7 changes: 7 additions & 0 deletions browser/base/content/test/urlbar/browser_canonizeURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ var pairs = [
];

add_task(function*() {
// Disable autoFill for this test, since it could mess up the results.
let autoFill = Preferences.get("browser.urlbar.autoFill");
Preferences.set("browser.urlbar.autoFill", false);
registerCleanupFunction(() => {
Preferences.set("browser.urlbar.autoFill", autoFill);
});

for (let [inputValue, expectedURL] of pairs) {
let focusEventPromise = BrowserTestUtils.waitForEvent(gURLBar, "focus");
let messagePromise = BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager,
Expand Down
2 changes: 2 additions & 0 deletions browser/base/content/test/urlbar/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
"resource://testing-common/PlacesTestUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabCrashHandler",
"resource:///modules/ContentCrashHandlers.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
"resource://gre/modules/Preferences.jsm");

function waitForCondition(condition, nextTest, errorMsg, retryTimes) {
retryTimes = typeof retryTimes !== 'undefined' ? retryTimes : 30;
Expand Down
101 changes: 67 additions & 34 deletions browser/base/content/urlbarBindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.

<field name="_value">""</field>
<field name="gotResultForCurrentQuery">false</field>
<field name="handleEnterWhenGotResult">false</field>

<!--
This is set around HandleHenter so it can be used in handleCommand.
It is also used to track whether we must handle a delayed handleEnter,
by checking if it has been cleared.
-->
<field name="handleEnterInstance">null</field>

<!--
For performance reasons we want to limit the size of the text runs we
Expand Down Expand Up @@ -387,6 +393,10 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
}

let url = this.value;
if (!url) {
return;
}

let mayInheritPrincipal = false;
let postData = null;
let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
Expand Down Expand Up @@ -452,12 +462,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
}
}

this._canonizeURL(event, response => {
[url, postData, mayInheritPrincipal] = response;
url = this._canonizeURL(event, url);
getShortcutOrURIAndPostData(url).then(({url, postData, mayInheritPrincipal}) => {
if (url) {
matchLastLocationChange =
lastLocationChange ==
gBrowser.selectedBrowser.lastLocationChange;
lastLocationChange == gBrowser.selectedBrowser.lastLocationChange;
this._loadURL(url, postData, where, openUILinkParams,
matchLastLocationChange, mayInheritPrincipal);
}
Expand All @@ -469,8 +478,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<getter><![CDATA[
// this.textValue may be an autofilled string. Search only with the
// portion that the user typed, if any, by preferring the autocomplete
// controller's searchString (including _searchStringOnHandleEnter).
return this._searchStringOnHandleEnter ||
// controller's searchString (including handleEnterInstance.searchString).
return (this.handleEnterInstance && this.handleEnterInstance.searchString) ||
this.mController.searchString ||
this.textValue;
]]></getter>
Expand Down Expand Up @@ -567,13 +576,9 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.

<method name="_canonizeURL">
<parameter name="aTriggeringEvent"/>
<parameter name="aCallback"/>
<parameter name="aUrl"/>
<body><![CDATA[
var url = this.value;
if (!url) {
aCallback(["", null, false]);
return;
}
let url = aUrl;

// Only add the suffix when the URL bar value isn't already "URL-like",
// and only if we get a keyboard event, to match user expectations.
Expand Down Expand Up @@ -624,9 +629,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
}
}

getShortcutOrURIAndPostData(url).then(data => {
aCallback([data.url, data.postData, data.mayInheritPrincipal]);
});
return url;
]]></body>
</method>

Expand Down Expand Up @@ -1005,8 +1008,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this._value = this.inputField.value;
gBrowser.userTypedValue = this.value;
this.valueIsTyped = true;
this.gotResultForCurrentQuery = false;
this.mController.handleText();
// Only wait for a result when we are sure to get one. In some
// cases, like when pasting the same exact text, we may not fire
// a new search and we won't get a result.
if (this.mController.handleText()) {
this.gotResultForCurrentQuery = false;
}
}
this.resetActionType();
]]></body>
Expand All @@ -1029,18 +1036,22 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// However, if the default result is automatically selected, we
// ensure that it corresponds to the current input.

// Store the current search string so it can be used in
// handleCommand, which will be called as a result of
// mController.handleEnter().
// Note this is also used to detect if we should perform a delayed
// handleEnter, in such a case it won't have been cleared.
this.handleEnterInstance = {
searchString: this.mController.searchString,
event: event
};

if (this.popup.selectedIndex != 0 || this.gotResultForCurrentQuery) {
// Store the current search string so it can be used in
// handleCommand, which will be called as a result of
// mController.handleEnter(). handleEnter will reset it.
this._searchStringOnHandleEnter = this.mController.searchString;
let rv = this.mController.handleEnter(false, event);
delete this._searchStringOnHandleEnter;
this.handleEnterInstance = null;
return rv;
}

this.handleEnterWhenGotResult = true;

return true;
]]></body>
</method>
Expand All @@ -1053,7 +1064,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// a backspace on the text value instead of removing the result.
if (this.popup.selectedIndex == 0 &&
this.popup._isFirstResultHeuristic) {
return this.mController.handleText();
this.mController.handleText();
return false;
}
return this.mController.handleDelete();
]]></body>
Expand Down Expand Up @@ -1751,27 +1763,48 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// If nothing is selected yet, select the first result if it is a
// pre-selected "heuristic" result. (See UnifiedComplete.js.)
if (this.selectedIndex == -1 && this._isFirstResultHeuristic) {
// Don't handle this as a user-initiated action.
this._ignoreNextSelect = true;

// Don't fire DOMMenuItemActive so that screen readers still see
// the input as being focused.
this.richlistbox.suppressMenuItemEvent = true;

this.selectedIndex = 0;
this.richlistbox.suppressMenuItemEvent = false;
this._ignoreNextSelect = false;
}

this.input.gotResultForCurrentQuery = true;
if (this.input.handleEnterWhenGotResult) {
this.input.handleEnterWhenGotResult = false;
this.input.mController.handleEnter(false);

// Check if we should perform a delayed handleEnter.
if (this.input.handleEnterInstance) {
try {
// Safety check: handle only if the search string didn't change.
let instance = this.input.handleEnterInstance;
if (this.input.mController.searchString == instance.searchString) {
this.input.mController.handleEnter(false, instance.event);
}
} finally {
this.input.handleEnterInstance = null;
}
}
]]>
</body>
</method>

<method name="_onSearchBegin">
<body><![CDATA[
// Set the selected index to 0 (heuristic) until a result comes back
// and we can evaluate it better.
//
// This is required to properly manage delayed handleEnter:
// 1. if a search starts we set selectedIndex to 0 here, and it will
// be updated by onResultsAdded. Since selectedIndex is 0,
// handleEnter will delay the action if a result didn't arrive yet.
// 2. if a search doesn't start (for example if autocomplete is
// disabled), this won't be called, and the selectedIndex will be
// the default -1 value. Then handleEnter will know it should not
// delay the action, cause a result wont't ever arrive.
this.selectedIndex = 0;
]]></body>
</method>

</implementation>
<handlers>

Expand Down
Loading

0 comments on commit 0677d5d

Please sign in to comment.