зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1616700) for causing failures in browser_privatebrowsing_about.js
Backed out changeset 5e1b8f75fef5 (bug 1616700) Backed out changeset fdf97a561019 (bug 1616700) Backed out changeset de3717cc63ef (bug 1616700)
This commit is contained in:
Родитель
58408449f9
Коммит
ddfba392b6
|
@ -57,14 +57,23 @@ class AboutPrivateBrowsingParent extends JSWindowActorParent {
|
|||
break;
|
||||
}
|
||||
case "SearchHandoff": {
|
||||
let searchAlias = "";
|
||||
let searchEngine = Services.search.defaultPrivateEngine;
|
||||
let searchAliases = searchEngine.aliases;
|
||||
if (searchAliases && searchAliases.length) {
|
||||
searchAlias = `${searchAliases[0]} `;
|
||||
}
|
||||
let urlBar = win.gURLBar;
|
||||
let isFirstChange = true;
|
||||
|
||||
if (!aMessage.data || !aMessage.data.text) {
|
||||
urlBar.setHiddenFocus();
|
||||
} else {
|
||||
// Pass the provided text to the awesomebar
|
||||
urlBar.search(aMessage.data.text);
|
||||
// Pass the provided text to the awesomebar. Prepend the @engine shortcut.
|
||||
urlBar.search(`${searchAlias}${aMessage.data.text}`, {
|
||||
searchEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
isFirstChange = false;
|
||||
}
|
||||
|
||||
|
@ -75,8 +84,11 @@ class AboutPrivateBrowsingParent extends JSWindowActorParent {
|
|||
if (isFirstChange) {
|
||||
isFirstChange = false;
|
||||
urlBar.removeHiddenFocus();
|
||||
urlBar.search("");
|
||||
this.sendAsyncMessage("DisableSearch");
|
||||
urlBar.search(searchAlias, {
|
||||
searchEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
this.sendAsyncMessage("HideSearch");
|
||||
urlBar.removeEventListener("compositionstart", checkFirstChange);
|
||||
urlBar.removeEventListener("paste", checkFirstChange);
|
||||
}
|
||||
|
@ -112,13 +124,6 @@ class AboutPrivateBrowsingParent extends JSWindowActorParent {
|
|||
urlBar.addEventListener("paste", checkFirstChange);
|
||||
break;
|
||||
}
|
||||
case "ShouldShowSearch": {
|
||||
return new Promise(resolve => {
|
||||
Services.search.getDefaultPrivate().then(engine => {
|
||||
resolve(engine.isAppProvided ? engine.name : null);
|
||||
});
|
||||
});
|
||||
}
|
||||
case "ShouldShowSearchBanner": {
|
||||
// If this is a pre-loaded private browsing new tab, then we don't want
|
||||
// to display the banner - it might never get displayed to the user
|
||||
|
|
|
@ -43,7 +43,6 @@ for (const type of [
|
|||
"DELETE_HISTORY_URL",
|
||||
"DIALOG_CANCEL",
|
||||
"DIALOG_OPEN",
|
||||
"DISABLE_SEARCH",
|
||||
"DISCOVERY_STREAM_COLLECTION_DISMISSIBLE_TOGGLE",
|
||||
"DISCOVERY_STREAM_CONFIG_CHANGE",
|
||||
"DISCOVERY_STREAM_CONFIG_RESET",
|
||||
|
@ -77,6 +76,7 @@ for (const type of [
|
|||
"FILL_SEARCH_TERM",
|
||||
"HANDOFF_SEARCH_TO_AWESOMEBAR",
|
||||
"HIDE_PRIVACY_INFO",
|
||||
"HIDE_SEARCH",
|
||||
"INIT",
|
||||
"NEW_TAB_INIT",
|
||||
"NEW_TAB_INITIAL_STATE",
|
||||
|
|
|
@ -808,12 +808,12 @@ function DiscoveryStream(prevState = INITIAL_STATE.DiscoveryStream, action) {
|
|||
|
||||
function Search(prevState = INITIAL_STATE.Search, action) {
|
||||
switch (action.type) {
|
||||
case at.DISABLE_SEARCH:
|
||||
return Object.assign({ ...prevState, disable: true });
|
||||
case at.HIDE_SEARCH:
|
||||
return Object.assign({ ...prevState, hide: true });
|
||||
case at.FAKE_FOCUS_SEARCH:
|
||||
return Object.assign({ ...prevState, fakeFocus: true });
|
||||
case at.SHOW_SEARCH:
|
||||
return Object.assign({ ...prevState, disable: false, fakeFocus: false });
|
||||
return Object.assign({ ...prevState, hide: false, fakeFocus: false });
|
||||
default:
|
||||
return prevState;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ export class _Search extends React.PureComponent {
|
|||
this.props.dispatch({ type: at.FAKE_FOCUS_SEARCH });
|
||||
this.props.dispatch(ac.UserEvent({ event: "SEARCH_HANDOFF" }));
|
||||
if (text) {
|
||||
this.props.dispatch({ type: at.DISABLE_SEARCH });
|
||||
this.props.dispatch({ type: at.HIDE_SEARCH });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,35 +112,6 @@ export class _Search extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
getDefaultEngineName() {
|
||||
// _handoffSearchController will manage engine names once it is initialized.
|
||||
return this.props.Prefs.values["urlbar.placeholderName"];
|
||||
}
|
||||
|
||||
getHandoffInputL10nAttributes() {
|
||||
let defaultEngineName = this.getDefaultEngineName();
|
||||
return defaultEngineName
|
||||
? {
|
||||
"data-l10n-id": "newtab-search-box-handoff-input",
|
||||
"data-l10n-args": `{"engine": "${defaultEngineName}"}`,
|
||||
}
|
||||
: {
|
||||
"data-l10n-id": "newtab-search-box-handoff-input-no-engine",
|
||||
};
|
||||
}
|
||||
|
||||
getHandoffTextL10nAttributes() {
|
||||
let defaultEngineName = this.getDefaultEngineName();
|
||||
return defaultEngineName
|
||||
? {
|
||||
"data-l10n-id": "newtab-search-box-handoff-text",
|
||||
"data-l10n-args": `{"engine": "${defaultEngineName}"}`,
|
||||
}
|
||||
: {
|
||||
"data-l10n-id": "newtab-search-box-handoff-text-no-engine",
|
||||
};
|
||||
}
|
||||
|
||||
onSearchHandoffButtonMount(button) {
|
||||
// Keep a reference to the button for use during "paste" event handling.
|
||||
this._searchHandoffButton = button;
|
||||
|
@ -154,7 +125,7 @@ export class _Search extends React.PureComponent {
|
|||
render() {
|
||||
const wrapperClassName = [
|
||||
"search-wrapper",
|
||||
this.props.disable && "search-disabled",
|
||||
this.props.hide && "search-hidden",
|
||||
this.props.fakeFocus && "fake-focus",
|
||||
]
|
||||
.filter(v => v)
|
||||
|
@ -196,14 +167,22 @@ export class _Search extends React.PureComponent {
|
|||
<div className="search-inner-wrapper">
|
||||
<button
|
||||
className="search-handoff-button"
|
||||
{...this.getHandoffInputL10nAttributes()}
|
||||
data-l10n-id={
|
||||
isNewNewtabExperienceEnabled
|
||||
? "newtab-search-box-input"
|
||||
: "newtab-search-box-search-the-web-input"
|
||||
}
|
||||
ref={this.onSearchHandoffButtonMount}
|
||||
onClick={this.onSearchHandoffClick}
|
||||
tabIndex="-1"
|
||||
>
|
||||
<div
|
||||
className="fake-textbox"
|
||||
{...this.getHandoffTextL10nAttributes()}
|
||||
data-l10n-id={
|
||||
isNewNewtabExperienceEnabled
|
||||
? "newtab-search-box-text"
|
||||
: "newtab-search-box-search-the-web-text"
|
||||
}
|
||||
/>
|
||||
<input
|
||||
type="search"
|
||||
|
|
|
@ -53,7 +53,7 @@ $glyph-forward: url('chrome://browser/skin/forward.svg');
|
|||
box-shadow: 0 0 0 2px var(--newtab-focus-outline);
|
||||
}
|
||||
|
||||
&.fake-focus:not(.search.disabled) {
|
||||
&.fake-focus {
|
||||
.search-handoff-button {
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline);
|
||||
|
@ -267,6 +267,7 @@ $glyph-forward: url('chrome://browser/skin/forward.svg');
|
|||
padding-inline-end: 48px;
|
||||
padding-inline-start: 46px;
|
||||
opacity: 1;
|
||||
transition: opacity 500ms;
|
||||
width: 100%;
|
||||
|
||||
&:dir(rtl) {
|
||||
|
@ -277,7 +278,7 @@ $glyph-forward: url('chrome://browser/skin/forward.svg');
|
|||
box-shadow: $shadow-secondary, 0 0 0 1px $black-25;
|
||||
}
|
||||
|
||||
.fake-focus:not(.search-disabled) & {
|
||||
.fake-focus & {
|
||||
border: $input-border-active;
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow);
|
||||
|
||||
|
@ -286,9 +287,9 @@ $glyph-forward: url('chrome://browser/skin/forward.svg');
|
|||
}
|
||||
}
|
||||
|
||||
.search-disabled & {
|
||||
opacity: 0.5;
|
||||
box-shadow: none;
|
||||
.search-hidden & {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.fake-editable:focus {
|
||||
|
|
|
@ -1300,7 +1300,7 @@ main {
|
|||
outline: 0;
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline); }
|
||||
.outer-wrapper.newtab-experience .search-wrapper.fake-focus:not(.search.disabled) .search-handoff-button {
|
||||
.outer-wrapper.newtab-experience .search-wrapper.fake-focus .search-handoff-button {
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline); }
|
||||
.outer-wrapper.newtab-experience .search-wrapper .search-handoff-button,
|
||||
|
@ -1444,19 +1444,20 @@ main {
|
|||
padding-inline-end: 48px;
|
||||
padding-inline-start: 46px;
|
||||
opacity: 1;
|
||||
transition: opacity 500ms;
|
||||
width: 100%; }
|
||||
.search-handoff-button:dir(rtl) {
|
||||
background-position-x: right 12px; }
|
||||
.search-handoff-button:hover {
|
||||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
.fake-focus:not(.search-disabled) .search-handoff-button {
|
||||
.fake-focus .search-handoff-button {
|
||||
border: 1px solid var(--newtab-textbox-focus-color);
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow); }
|
||||
.fake-focus:not(.search-disabled) .search-handoff-button .fake-caret {
|
||||
.fake-focus .search-handoff-button .fake-caret {
|
||||
display: block; }
|
||||
.search-disabled .search-handoff-button {
|
||||
opacity: 0.5;
|
||||
box-shadow: none; }
|
||||
.search-hidden .search-handoff-button {
|
||||
opacity: 0;
|
||||
visibility: hidden; }
|
||||
.search-handoff-button .fake-editable:focus {
|
||||
outline: none;
|
||||
caret-color: transparent; }
|
||||
|
|
|
@ -1303,7 +1303,7 @@ main {
|
|||
outline: 0;
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline); }
|
||||
.outer-wrapper.newtab-experience .search-wrapper.fake-focus:not(.search.disabled) .search-handoff-button {
|
||||
.outer-wrapper.newtab-experience .search-wrapper.fake-focus .search-handoff-button {
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline); }
|
||||
.outer-wrapper.newtab-experience .search-wrapper .search-handoff-button,
|
||||
|
@ -1447,19 +1447,20 @@ main {
|
|||
padding-inline-end: 48px;
|
||||
padding-inline-start: 46px;
|
||||
opacity: 1;
|
||||
transition: opacity 500ms;
|
||||
width: 100%; }
|
||||
.search-handoff-button:dir(rtl) {
|
||||
background-position-x: right 12px; }
|
||||
.search-handoff-button:hover {
|
||||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
.fake-focus:not(.search-disabled) .search-handoff-button {
|
||||
.fake-focus .search-handoff-button {
|
||||
border: 1px solid var(--newtab-textbox-focus-color);
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow); }
|
||||
.fake-focus:not(.search-disabled) .search-handoff-button .fake-caret {
|
||||
.fake-focus .search-handoff-button .fake-caret {
|
||||
display: block; }
|
||||
.search-disabled .search-handoff-button {
|
||||
opacity: 0.5;
|
||||
box-shadow: none; }
|
||||
.search-hidden .search-handoff-button {
|
||||
opacity: 0;
|
||||
visibility: hidden; }
|
||||
.search-handoff-button .fake-editable:focus {
|
||||
outline: none;
|
||||
caret-color: transparent; }
|
||||
|
|
|
@ -1300,7 +1300,7 @@ main {
|
|||
outline: 0;
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline); }
|
||||
.outer-wrapper.newtab-experience .search-wrapper.fake-focus:not(.search.disabled) .search-handoff-button {
|
||||
.outer-wrapper.newtab-experience .search-wrapper.fake-focus .search-handoff-button {
|
||||
border: 1px solid var(--newtab-focus-border);
|
||||
box-shadow: 0 0 0 2px var(--newtab-focus-outline); }
|
||||
.outer-wrapper.newtab-experience .search-wrapper .search-handoff-button,
|
||||
|
@ -1444,19 +1444,20 @@ main {
|
|||
padding-inline-end: 48px;
|
||||
padding-inline-start: 46px;
|
||||
opacity: 1;
|
||||
transition: opacity 500ms;
|
||||
width: 100%; }
|
||||
.search-handoff-button:dir(rtl) {
|
||||
background-position-x: right 12px; }
|
||||
.search-handoff-button:hover {
|
||||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
.fake-focus:not(.search-disabled) .search-handoff-button {
|
||||
.fake-focus .search-handoff-button {
|
||||
border: 1px solid var(--newtab-textbox-focus-color);
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow); }
|
||||
.fake-focus:not(.search-disabled) .search-handoff-button .fake-caret {
|
||||
.fake-focus .search-handoff-button .fake-caret {
|
||||
display: block; }
|
||||
.search-disabled .search-handoff-button {
|
||||
opacity: 0.5;
|
||||
box-shadow: none; }
|
||||
.search-hidden .search-handoff-button {
|
||||
opacity: 0;
|
||||
visibility: hidden; }
|
||||
.search-handoff-button .fake-editable:focus {
|
||||
outline: none;
|
||||
caret-color: transparent; }
|
||||
|
|
|
@ -205,7 +205,7 @@ const globalImportContext = typeof Window === "undefined" ? BACKGROUND_PROCESS :
|
|||
// }
|
||||
const actionTypes = {};
|
||||
|
||||
for (const type of ["ABOUT_SPONSORED_TOP_SITES", "ADDONS_INFO_REQUEST", "ADDONS_INFO_RESPONSE", "ARCHIVE_FROM_POCKET", "AS_ROUTER_INITIALIZED", "AS_ROUTER_PREF_CHANGED", "AS_ROUTER_TARGETING_UPDATE", "AS_ROUTER_TELEMETRY_USER_EVENT", "BLOCK_URL", "BOOKMARK_URL", "CLEAR_PREF", "COPY_DOWNLOAD_LINK", "DELETE_BOOKMARK_BY_ID", "DELETE_FROM_POCKET", "DELETE_HISTORY_URL", "DIALOG_CANCEL", "DIALOG_OPEN", "DISABLE_SEARCH", "DISCOVERY_STREAM_COLLECTION_DISMISSIBLE_TOGGLE", "DISCOVERY_STREAM_CONFIG_CHANGE", "DISCOVERY_STREAM_CONFIG_RESET", "DISCOVERY_STREAM_CONFIG_RESET_DEFAULTS", "DISCOVERY_STREAM_CONFIG_SETUP", "DISCOVERY_STREAM_CONFIG_SET_VALUE", "DISCOVERY_STREAM_DEV_EXPIRE_CACHE", "DISCOVERY_STREAM_DEV_IDLE_DAILY", "DISCOVERY_STREAM_DEV_SYNC_RS", "DISCOVERY_STREAM_DEV_SYSTEM_TICK", "DISCOVERY_STREAM_FEEDS_UPDATE", "DISCOVERY_STREAM_FEED_UPDATE", "DISCOVERY_STREAM_IMPRESSION_STATS", "DISCOVERY_STREAM_LAYOUT_RESET", "DISCOVERY_STREAM_LAYOUT_UPDATE", "DISCOVERY_STREAM_LINK_BLOCKED", "DISCOVERY_STREAM_LOADED_CONTENT", "DISCOVERY_STREAM_PERSONALIZATION_INIT", "DISCOVERY_STREAM_PERSONALIZATION_LAST_UPDATED", "DISCOVERY_STREAM_PERSONALIZATION_VERSION", "DISCOVERY_STREAM_PERSONALIZATION_VERSION_TOGGLE", "DISCOVERY_STREAM_RETRY_FEED", "DISCOVERY_STREAM_SPOCS_CAPS", "DISCOVERY_STREAM_SPOCS_ENDPOINT", "DISCOVERY_STREAM_SPOCS_PLACEMENTS", "DISCOVERY_STREAM_SPOCS_UPDATE", "DISCOVERY_STREAM_SPOC_BLOCKED", "DISCOVERY_STREAM_SPOC_IMPRESSION", "DOWNLOAD_CHANGED", "FAKE_FOCUS_SEARCH", "FILL_SEARCH_TERM", "HANDOFF_SEARCH_TO_AWESOMEBAR", "HIDE_PRIVACY_INFO", "INIT", "NEW_TAB_INIT", "NEW_TAB_INITIAL_STATE", "NEW_TAB_LOAD", "NEW_TAB_REHYDRATED", "NEW_TAB_STATE_REQUEST", "NEW_TAB_UNLOAD", "OPEN_DOWNLOAD_FILE", "OPEN_LINK", "OPEN_NEW_WINDOW", "OPEN_PRIVATE_WINDOW", "OPEN_WEBEXT_SETTINGS", "PARTNER_LINK_ATTRIBUTION", "PLACES_BOOKMARKS_REMOVED", "PLACES_BOOKMARK_ADDED", "PLACES_HISTORY_CLEARED", "PLACES_LINKS_CHANGED", "PLACES_LINKS_DELETED", "PLACES_LINK_BLOCKED", "PLACES_SAVED_TO_POCKET", "POCKET_CTA", "POCKET_LINK_DELETED_OR_ARCHIVED", "POCKET_LOGGED_IN", "POCKET_WAITING_FOR_SPOC", "PREFS_INITIAL_VALUES", "PREF_CHANGED", "PREVIEW_REQUEST", "PREVIEW_REQUEST_CANCEL", "PREVIEW_RESPONSE", "REMOVE_DOWNLOAD_FILE", "RICH_ICON_MISSING", "SAVE_SESSION_PERF_DATA", "SAVE_TO_POCKET", "SCREENSHOT_UPDATED", "SECTION_DEREGISTER", "SECTION_DISABLE", "SECTION_ENABLE", "SECTION_MOVE", "SECTION_OPTIONS_CHANGED", "SECTION_REGISTER", "SECTION_UPDATE", "SECTION_UPDATE_CARD", "SETTINGS_CLOSE", "SETTINGS_OPEN", "SET_PREF", "SHOW_DOWNLOAD_FILE", "SHOW_FIREFOX_ACCOUNTS", "SHOW_PRIVACY_INFO", "SHOW_SEARCH", "SKIPPED_SIGNIN", "SNIPPETS_BLOCKLIST_CLEARED", "SNIPPETS_BLOCKLIST_UPDATED", "SNIPPETS_DATA", "SNIPPETS_PREVIEW_MODE", "SNIPPETS_RESET", "SNIPPET_BLOCKED", "SUBMIT_EMAIL", "SUBMIT_SIGNIN", "SYSTEM_TICK", "TELEMETRY_IMPRESSION_STATS", "TELEMETRY_USER_EVENT", "TOP_SITES_CANCEL_EDIT", "TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL", "TOP_SITES_EDIT", "TOP_SITES_IMPRESSION_STATS", "TOP_SITES_INSERT", "TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL", "TOP_SITES_PIN", "TOP_SITES_PREFS_UPDATED", "TOP_SITES_UNPIN", "TOP_SITES_UPDATED", "TOTAL_BOOKMARKS_REQUEST", "TOTAL_BOOKMARKS_RESPONSE", "UNINIT", "UPDATE_PINNED_SEARCH_SHORTCUTS", "UPDATE_SEARCH_SHORTCUTS", "UPDATE_SECTION_PREFS", "WEBEXT_CLICK", "WEBEXT_DISMISS"]) {
|
||||
for (const type of ["ABOUT_SPONSORED_TOP_SITES", "ADDONS_INFO_REQUEST", "ADDONS_INFO_RESPONSE", "ARCHIVE_FROM_POCKET", "AS_ROUTER_INITIALIZED", "AS_ROUTER_PREF_CHANGED", "AS_ROUTER_TARGETING_UPDATE", "AS_ROUTER_TELEMETRY_USER_EVENT", "BLOCK_URL", "BOOKMARK_URL", "CLEAR_PREF", "COPY_DOWNLOAD_LINK", "DELETE_BOOKMARK_BY_ID", "DELETE_FROM_POCKET", "DELETE_HISTORY_URL", "DIALOG_CANCEL", "DIALOG_OPEN", "DISCOVERY_STREAM_COLLECTION_DISMISSIBLE_TOGGLE", "DISCOVERY_STREAM_CONFIG_CHANGE", "DISCOVERY_STREAM_CONFIG_RESET", "DISCOVERY_STREAM_CONFIG_RESET_DEFAULTS", "DISCOVERY_STREAM_CONFIG_SETUP", "DISCOVERY_STREAM_CONFIG_SET_VALUE", "DISCOVERY_STREAM_DEV_EXPIRE_CACHE", "DISCOVERY_STREAM_DEV_IDLE_DAILY", "DISCOVERY_STREAM_DEV_SYNC_RS", "DISCOVERY_STREAM_DEV_SYSTEM_TICK", "DISCOVERY_STREAM_FEEDS_UPDATE", "DISCOVERY_STREAM_FEED_UPDATE", "DISCOVERY_STREAM_IMPRESSION_STATS", "DISCOVERY_STREAM_LAYOUT_RESET", "DISCOVERY_STREAM_LAYOUT_UPDATE", "DISCOVERY_STREAM_LINK_BLOCKED", "DISCOVERY_STREAM_LOADED_CONTENT", "DISCOVERY_STREAM_PERSONALIZATION_INIT", "DISCOVERY_STREAM_PERSONALIZATION_LAST_UPDATED", "DISCOVERY_STREAM_PERSONALIZATION_VERSION", "DISCOVERY_STREAM_PERSONALIZATION_VERSION_TOGGLE", "DISCOVERY_STREAM_RETRY_FEED", "DISCOVERY_STREAM_SPOCS_CAPS", "DISCOVERY_STREAM_SPOCS_ENDPOINT", "DISCOVERY_STREAM_SPOCS_PLACEMENTS", "DISCOVERY_STREAM_SPOCS_UPDATE", "DISCOVERY_STREAM_SPOC_BLOCKED", "DISCOVERY_STREAM_SPOC_IMPRESSION", "DOWNLOAD_CHANGED", "FAKE_FOCUS_SEARCH", "FILL_SEARCH_TERM", "HANDOFF_SEARCH_TO_AWESOMEBAR", "HIDE_PRIVACY_INFO", "HIDE_SEARCH", "INIT", "NEW_TAB_INIT", "NEW_TAB_INITIAL_STATE", "NEW_TAB_LOAD", "NEW_TAB_REHYDRATED", "NEW_TAB_STATE_REQUEST", "NEW_TAB_UNLOAD", "OPEN_DOWNLOAD_FILE", "OPEN_LINK", "OPEN_NEW_WINDOW", "OPEN_PRIVATE_WINDOW", "OPEN_WEBEXT_SETTINGS", "PARTNER_LINK_ATTRIBUTION", "PLACES_BOOKMARKS_REMOVED", "PLACES_BOOKMARK_ADDED", "PLACES_HISTORY_CLEARED", "PLACES_LINKS_CHANGED", "PLACES_LINKS_DELETED", "PLACES_LINK_BLOCKED", "PLACES_SAVED_TO_POCKET", "POCKET_CTA", "POCKET_LINK_DELETED_OR_ARCHIVED", "POCKET_LOGGED_IN", "POCKET_WAITING_FOR_SPOC", "PREFS_INITIAL_VALUES", "PREF_CHANGED", "PREVIEW_REQUEST", "PREVIEW_REQUEST_CANCEL", "PREVIEW_RESPONSE", "REMOVE_DOWNLOAD_FILE", "RICH_ICON_MISSING", "SAVE_SESSION_PERF_DATA", "SAVE_TO_POCKET", "SCREENSHOT_UPDATED", "SECTION_DEREGISTER", "SECTION_DISABLE", "SECTION_ENABLE", "SECTION_MOVE", "SECTION_OPTIONS_CHANGED", "SECTION_REGISTER", "SECTION_UPDATE", "SECTION_UPDATE_CARD", "SETTINGS_CLOSE", "SETTINGS_OPEN", "SET_PREF", "SHOW_DOWNLOAD_FILE", "SHOW_FIREFOX_ACCOUNTS", "SHOW_PRIVACY_INFO", "SHOW_SEARCH", "SKIPPED_SIGNIN", "SNIPPETS_BLOCKLIST_CLEARED", "SNIPPETS_BLOCKLIST_UPDATED", "SNIPPETS_DATA", "SNIPPETS_PREVIEW_MODE", "SNIPPETS_RESET", "SNIPPET_BLOCKED", "SUBMIT_EMAIL", "SUBMIT_SIGNIN", "SYSTEM_TICK", "TELEMETRY_IMPRESSION_STATS", "TELEMETRY_USER_EVENT", "TOP_SITES_CANCEL_EDIT", "TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL", "TOP_SITES_EDIT", "TOP_SITES_IMPRESSION_STATS", "TOP_SITES_INSERT", "TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL", "TOP_SITES_PIN", "TOP_SITES_PREFS_UPDATED", "TOP_SITES_UNPIN", "TOP_SITES_UPDATED", "TOTAL_BOOKMARKS_REQUEST", "TOTAL_BOOKMARKS_RESPONSE", "UNINIT", "UPDATE_PINNED_SEARCH_SHORTCUTS", "UPDATE_SEARCH_SHORTCUTS", "UPDATE_SECTION_PREFS", "WEBEXT_CLICK", "WEBEXT_DISMISS"]) {
|
||||
actionTypes[type] = type;
|
||||
} // Helper function for creating routed actions between content and main
|
||||
// Not intended to be used by consumers
|
||||
|
@ -10431,8 +10431,6 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* globals ContentSearchUIController, ContentSearchHandoffUIController */
|
||||
|
||||
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10478,7 +10476,7 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
|
|||
|
||||
if (text) {
|
||||
this.props.dispatch({
|
||||
type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].DISABLE_SEARCH
|
||||
type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].HIDE_SEARCH
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -10543,31 +10541,6 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
|
|||
}
|
||||
}
|
||||
|
||||
getDefaultEngineName() {
|
||||
// _handoffSearchController will manage engine names once it is initialized.
|
||||
return this.props.Prefs.values["urlbar.placeholderName"];
|
||||
}
|
||||
|
||||
getHandoffInputL10nAttributes() {
|
||||
let defaultEngineName = this.getDefaultEngineName();
|
||||
return defaultEngineName ? {
|
||||
"data-l10n-id": "newtab-search-box-handoff-input",
|
||||
"data-l10n-args": `{"engine": "${defaultEngineName}"}`
|
||||
} : {
|
||||
"data-l10n-id": "newtab-search-box-handoff-input-no-engine"
|
||||
};
|
||||
}
|
||||
|
||||
getHandoffTextL10nAttributes() {
|
||||
let defaultEngineName = this.getDefaultEngineName();
|
||||
return defaultEngineName ? {
|
||||
"data-l10n-id": "newtab-search-box-handoff-text",
|
||||
"data-l10n-args": `{"engine": "${defaultEngineName}"}`
|
||||
} : {
|
||||
"data-l10n-id": "newtab-search-box-handoff-text-no-engine"
|
||||
};
|
||||
}
|
||||
|
||||
onSearchHandoffButtonMount(button) {
|
||||
// Keep a reference to the button for use during "paste" event handling.
|
||||
this._searchHandoffButton = button;
|
||||
|
@ -10580,7 +10553,7 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
|
|||
|
||||
|
||||
render() {
|
||||
const wrapperClassName = ["search-wrapper", this.props.disable && "search-disabled", this.props.fakeFocus && "fake-focus"].filter(v => v).join(" ");
|
||||
const wrapperClassName = ["search-wrapper", this.props.hide && "search-hidden", this.props.fakeFocus && "fake-focus"].filter(v => v).join(" ");
|
||||
const isNewNewtabExperienceEnabled = this.props.Prefs.values.featureConfig.newNewtabExperienceEnabled;
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", {
|
||||
className: wrapperClassName
|
||||
|
@ -10605,15 +10578,16 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
|
|||
onClick: this.onSearchClick
|
||||
})), this.props.handoffEnabled && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", {
|
||||
className: "search-inner-wrapper"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("button", _extends({
|
||||
className: "search-handoff-button"
|
||||
}, this.getHandoffInputL10nAttributes(), {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("button", {
|
||||
className: "search-handoff-button",
|
||||
"data-l10n-id": isNewNewtabExperienceEnabled ? "newtab-search-box-input" : "newtab-search-box-search-the-web-input",
|
||||
ref: this.onSearchHandoffButtonMount,
|
||||
onClick: this.onSearchHandoffClick,
|
||||
tabIndex: "-1"
|
||||
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", _extends({
|
||||
className: "fake-textbox"
|
||||
}, this.getHandoffTextL10nAttributes())), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("input", {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", {
|
||||
className: "fake-textbox",
|
||||
"data-l10n-id": isNewNewtabExperienceEnabled ? "newtab-search-box-text" : "newtab-search-box-search-the-web-text"
|
||||
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("input", {
|
||||
type: "search",
|
||||
className: "fake-editable",
|
||||
tabIndex: "-1",
|
||||
|
@ -15706,9 +15680,9 @@ function DiscoveryStream(prevState = INITIAL_STATE.DiscoveryStream, action) {
|
|||
|
||||
function Search(prevState = INITIAL_STATE.Search, action) {
|
||||
switch (action.type) {
|
||||
case Actions["actionTypes"].DISABLE_SEARCH:
|
||||
case Actions["actionTypes"].HIDE_SEARCH:
|
||||
return Object.assign({ ...prevState,
|
||||
disable: true
|
||||
hide: true
|
||||
});
|
||||
|
||||
case Actions["actionTypes"].FAKE_FOCUS_SEARCH:
|
||||
|
@ -15718,7 +15692,7 @@ function Search(prevState = INITIAL_STATE.Search, action) {
|
|||
|
||||
case Actions["actionTypes"].SHOW_SEARCH:
|
||||
return Object.assign({ ...prevState,
|
||||
disable: false,
|
||||
hide: false,
|
||||
fakeFocus: false
|
||||
});
|
||||
|
||||
|
|
|
@ -24,6 +24,11 @@ ChromeUtils.defineModuleGetter(
|
|||
"PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm"
|
||||
);
|
||||
|
||||
const LINK_BLOCKED_EVENT = "newtab-linkBlocked";
|
||||
const PLACES_LINKS_CHANGED_DELAY_TIME = 1000; // time in ms to delay timer for places links changed events
|
||||
|
@ -379,14 +384,35 @@ class PlacesFeed {
|
|||
});
|
||||
}
|
||||
|
||||
_getDefaultSearchEngine(isPrivateWindow) {
|
||||
return Services.search[
|
||||
isPrivateWindow ? "defaultPrivateEngine" : "defaultEngine"
|
||||
];
|
||||
}
|
||||
|
||||
_getSearchPrefix(searchEngine) {
|
||||
const searchAliases = searchEngine.aliases;
|
||||
if (searchAliases && searchAliases.length) {
|
||||
return `${searchAliases[0]} `;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
handoffSearchToAwesomebar({ _target, data, meta }) {
|
||||
const searchEngine = this._getDefaultSearchEngine(
|
||||
PrivateBrowsingUtils.isBrowserPrivate(_target.browser)
|
||||
);
|
||||
const searchAlias = this._getSearchPrefix(searchEngine);
|
||||
const urlBar = _target.browser.ownerGlobal.gURLBar;
|
||||
let isFirstChange = true;
|
||||
|
||||
if (!data || !data.text) {
|
||||
urlBar.setHiddenFocus();
|
||||
} else {
|
||||
urlBar.search(data.text);
|
||||
urlBar.search(searchAlias + data.text, {
|
||||
searchEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
isFirstChange = false;
|
||||
}
|
||||
|
||||
|
@ -397,9 +423,12 @@ class PlacesFeed {
|
|||
if (isFirstChange) {
|
||||
isFirstChange = false;
|
||||
urlBar.removeHiddenFocus();
|
||||
urlBar.search("");
|
||||
urlBar.search(searchAlias, {
|
||||
searchEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
this.store.dispatch(
|
||||
ac.OnlyToOneContent({ type: at.DISABLE_SEARCH }, meta.fromTarget)
|
||||
ac.OnlyToOneContent({ type: at.HIDE_SEARCH }, meta.fromTarget)
|
||||
);
|
||||
urlBar.removeEventListener("compositionstart", checkFirstChange);
|
||||
urlBar.removeEventListener("paste", checkFirstChange);
|
||||
|
|
|
@ -135,7 +135,7 @@ this.PrefsFeed = class PrefsFeed {
|
|||
);
|
||||
|
||||
// Read the pref for search shortcuts top sites experiment from firefox.js and store it
|
||||
// in our internal list of prefs to watch
|
||||
// in our interal list of prefs to watch
|
||||
let searchTopSiteExperimentPrefValue = Services.prefs.getBoolPref(
|
||||
"browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts"
|
||||
);
|
||||
|
@ -151,7 +151,7 @@ this.PrefsFeed = class PrefsFeed {
|
|||
);
|
||||
|
||||
// Read the pref for search hand-off from firefox.js and store it
|
||||
// in our internal list of prefs to watch
|
||||
// in our interal list of prefs to watch
|
||||
let handoffToAwesomebarPrefValue = Services.prefs.getBoolPref(
|
||||
"browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar"
|
||||
);
|
||||
|
@ -160,17 +160,6 @@ this.PrefsFeed = class PrefsFeed {
|
|||
value: handoffToAwesomebarPrefValue,
|
||||
});
|
||||
|
||||
// Read the pref for the cached default engine name from firefox.js and
|
||||
// store it in our internal list of prefs to watch
|
||||
let placeholderPrefValue = Services.prefs.getStringPref(
|
||||
"browser.urlbar.placeholderName",
|
||||
""
|
||||
);
|
||||
values["urlbar.placeholderName"] = placeholderPrefValue;
|
||||
this._prefMap.set("urlbar.placeholderName", {
|
||||
value: placeholderPrefValue,
|
||||
});
|
||||
|
||||
// Add experiment values and default values
|
||||
values.featureConfig = aboutNewTabFeature.getValue() || {};
|
||||
this._setBoolPref(values, "logowordmark.alwaysVisible", false);
|
||||
|
|
|
@ -1543,18 +1543,18 @@ describe("Reducers", () => {
|
|||
INITIAL_STATE.Search
|
||||
);
|
||||
});
|
||||
it("should set disable to true on DISABLE_SEARCH", () => {
|
||||
const nextState = Search(undefined, { type: "DISABLE_SEARCH" });
|
||||
assert.propertyVal(nextState, "disable", true);
|
||||
it("should set hide to true on HIDE_SEARCH", () => {
|
||||
const nextState = Search(undefined, { type: "HIDE_SEARCH" });
|
||||
assert.propertyVal(nextState, "hide", true);
|
||||
});
|
||||
it("should set focus to true on FAKE_FOCUS_SEARCH", () => {
|
||||
const nextState = Search(undefined, { type: "FAKE_FOCUS_SEARCH" });
|
||||
assert.propertyVal(nextState, "fakeFocus", true);
|
||||
});
|
||||
it("should set focus and disable to false on SHOW_SEARCH", () => {
|
||||
it("should set focus and hide to false on SHOW_SEARCH", () => {
|
||||
const nextState = Search(undefined, { type: "SHOW_SEARCH" });
|
||||
assert.propertyVal(nextState, "fakeFocus", false);
|
||||
assert.propertyVal(nextState, "disable", false);
|
||||
assert.propertyVal(nextState, "hide", false);
|
||||
});
|
||||
});
|
||||
it("should set initialized to true on AS_ROUTER_INITIALIZED", () => {
|
||||
|
|
|
@ -145,7 +145,7 @@ describe("<Search>", () => {
|
|||
},
|
||||
type: "HANDOFF_SEARCH_TO_AWESOMEBAR",
|
||||
});
|
||||
assert.calledWith(dispatch, { type: "DISABLE_SEARCH" });
|
||||
assert.calledWith(dispatch, { type: "HIDE_SEARCH" });
|
||||
const [action] = dispatch.thirdCall.args;
|
||||
assert.isUserEventAction(action);
|
||||
assert.propertyVal(action.data, "event", "SEARCH_HANDOFF");
|
||||
|
@ -170,7 +170,7 @@ describe("<Search>", () => {
|
|||
},
|
||||
type: "HANDOFF_SEARCH_TO_AWESOMEBAR",
|
||||
});
|
||||
assert.calledWith(dispatch, { type: "DISABLE_SEARCH" });
|
||||
assert.calledWith(dispatch, { type: "HIDE_SEARCH" });
|
||||
const [action] = dispatch.thirdCall.args;
|
||||
assert.isUserEventAction(action);
|
||||
assert.propertyVal(action.data, "event", "SEARCH_HANDOFF");
|
||||
|
|
|
@ -616,7 +616,7 @@ describe("PlacesFeed", () => {
|
|||
to: "ActivityStream:Content",
|
||||
toTarget: {},
|
||||
},
|
||||
type: "DISABLE_SEARCH",
|
||||
type: "HIDE_SEARCH",
|
||||
});
|
||||
});
|
||||
it("should properly handle handoff with text data passed in", () => {
|
||||
|
@ -626,7 +626,10 @@ describe("PlacesFeed", () => {
|
|||
meta: { fromTarget: {} },
|
||||
});
|
||||
assert.calledOnce(fakeUrlBar.search);
|
||||
assert.calledWith(fakeUrlBar.search, "foo");
|
||||
assert.calledWith(fakeUrlBar.search, "@google foo", {
|
||||
searchEngine: global.Services.search.defaultEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
assert.notCalled(fakeUrlBar.focus);
|
||||
assert.notCalled(fakeUrlBar.setHiddenFocus);
|
||||
|
||||
|
@ -651,7 +654,10 @@ describe("PlacesFeed", () => {
|
|||
meta: { fromTarget: {} },
|
||||
});
|
||||
assert.calledOnce(fakeUrlBar.search);
|
||||
assert.calledWith(fakeUrlBar.search, "foo");
|
||||
assert.calledWith(fakeUrlBar.search, "@bing foo", {
|
||||
searchEngine: global.Services.search.defaultPrivateEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
assert.notCalled(fakeUrlBar.focus);
|
||||
assert.notCalled(fakeUrlBar.setHiddenFocus);
|
||||
|
||||
|
@ -676,7 +682,10 @@ describe("PlacesFeed", () => {
|
|||
meta: { fromTarget: {} },
|
||||
});
|
||||
assert.calledOnce(fakeUrlBar.search);
|
||||
assert.calledWithExactly(fakeUrlBar.search, "foo");
|
||||
assert.calledWithExactly(fakeUrlBar.search, "@google foo", {
|
||||
searchEngine: global.Services.search.defaultEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
assert.notCalled(fakeUrlBar.focus);
|
||||
|
||||
// Now call ESC keydown.
|
||||
|
@ -692,6 +701,19 @@ describe("PlacesFeed", () => {
|
|||
type: "SHOW_SEARCH",
|
||||
});
|
||||
});
|
||||
it("should properly handle no defined search alias", () => {
|
||||
global.Services.search.defaultEngine.aliases = [];
|
||||
feed.handoffSearchToAwesomebar({
|
||||
_target: { browser: { ownerGlobal: { gURLBar: fakeUrlBar } } },
|
||||
data: { text: "foo" },
|
||||
meta: { fromTarget: {} },
|
||||
});
|
||||
assert.calledOnce(fakeUrlBar.search);
|
||||
assert.calledWithExactly(fakeUrlBar.search, "foo", {
|
||||
searchEngine: global.Services.search.defaultEngine,
|
||||
searchModeEntry: "handoff",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#observe", () => {
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<div class="wordmark"></div>
|
||||
</div>
|
||||
<div class="search-inner-wrapper">
|
||||
<button id="search-handoff-button" class="search-handoff-button" tabindex="-1">
|
||||
<div class="fake-textbox"></div>
|
||||
<button id="search-handoff-button" class="search-handoff-button" tabindex="-1" data-l10n-id="about-private-browsing">
|
||||
<div class="fake-textbox" data-l10n-id="about-private-browsing-search-placeholder"></div>
|
||||
<input id="fake-editable" class="fake-editable" tabindex="-1" aria-hidden="true" />
|
||||
<div class="fake-caret"></div>
|
||||
</button>
|
||||
|
|
|
@ -89,59 +89,31 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
openSearchOptions.addEventListener("click", openSearchOptionsEvtHandler);
|
||||
openSearchOptions.addEventListener("keypress", openSearchOptionsEvtHandler);
|
||||
|
||||
// Load contentSearchUI so it sets the search engine icon and name for us.
|
||||
new window.ContentSearchHandoffUIController();
|
||||
|
||||
// Setup the search hand-off box.
|
||||
let btn = document.getElementById("search-handoff-button");
|
||||
RPMSendQuery("ShouldShowSearch", {}).then(engineName => {
|
||||
let input = document.querySelector(".fake-textbox");
|
||||
if (engineName) {
|
||||
document.l10n.setAttributes(btn, "about-private-browsing-handoff", {
|
||||
engine: engineName,
|
||||
});
|
||||
document.l10n.setAttributes(
|
||||
input,
|
||||
"about-private-browsing-handoff-text",
|
||||
{
|
||||
engine: engineName,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
document.l10n.setAttributes(
|
||||
btn,
|
||||
"about-private-browsing-handoff-no-engine"
|
||||
);
|
||||
document.l10n.setAttributes(
|
||||
input,
|
||||
"about-private-browsing-handoff-text-no-engine"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let editable = document.getElementById("fake-editable");
|
||||
let DISABLE_SEARCH_TOPIC = "DisableSearch";
|
||||
let HIDE_SEARCH_TOPIC = "HideSearch";
|
||||
let SHOW_SEARCH_TOPIC = "ShowSearch";
|
||||
let SEARCH_HANDOFF_TOPIC = "SearchHandoff";
|
||||
|
||||
function showSearch() {
|
||||
btn.classList.remove("focused");
|
||||
btn.classList.remove("disabled");
|
||||
btn.classList.remove("hidden");
|
||||
RPMRemoveMessageListener(SHOW_SEARCH_TOPIC, showSearch);
|
||||
}
|
||||
|
||||
function disableSearch() {
|
||||
btn.classList.add("disabled");
|
||||
function hideSearch() {
|
||||
btn.classList.add("hidden");
|
||||
}
|
||||
|
||||
function handoffSearch(text) {
|
||||
RPMSendAsyncMessage(SEARCH_HANDOFF_TOPIC, { text });
|
||||
RPMAddMessageListener(SHOW_SEARCH_TOPIC, showSearch);
|
||||
if (text) {
|
||||
disableSearch();
|
||||
hideSearch();
|
||||
} else {
|
||||
btn.classList.add("focused");
|
||||
RPMAddMessageListener(DISABLE_SEARCH_TOPIC, disableSearch);
|
||||
RPMAddMessageListener(HIDE_SEARCH_TOPIC, hideSearch);
|
||||
}
|
||||
}
|
||||
btn.addEventListener("focus", function() {
|
||||
|
@ -163,4 +135,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
ev.preventDefault();
|
||||
handoffSearch(ev.clipboardData.getData("Text"));
|
||||
});
|
||||
|
||||
// Load contentSearchUI so it sets the search engine icon for us.
|
||||
new window.ContentSearchHandoffUIController();
|
||||
});
|
||||
|
|
|
@ -109,7 +109,7 @@ add_task(async function test_search_handoff_on_keydown() {
|
|||
btn.click();
|
||||
ok(btn.classList.contains("focused"), "in-content search has focus styles");
|
||||
});
|
||||
ok(urlBarHasHiddenFocus(win), "Urlbar has hidden focus");
|
||||
ok(urlBarHasHiddenFocus(win), "url bar has hidden focused");
|
||||
|
||||
// Expect two searches, one to enter search mode and then another in search
|
||||
// mode.
|
||||
|
@ -120,15 +120,21 @@ add_task(async function test_search_handoff_on_keydown() {
|
|||
ok(
|
||||
content.document
|
||||
.getElementById("search-handoff-button")
|
||||
.classList.contains("disabled"),
|
||||
"in-content search is disabled"
|
||||
.classList.contains("hidden"),
|
||||
"in-content search is hidden"
|
||||
);
|
||||
});
|
||||
await searchPromise;
|
||||
ok(urlBarHasNormalFocus(win), "Urlbar has normal focus");
|
||||
ok(urlBarHasNormalFocus(win), "url bar has normal focused");
|
||||
await UrlbarTestUtils.assertSearchMode(win, {
|
||||
engineName: "DuckDuckGo",
|
||||
source: UrlbarUtils.RESULT_SOURCE.SEARCH,
|
||||
entry: "handoff",
|
||||
});
|
||||
is(win.gURLBar.value, "f", "url bar has search text");
|
||||
|
||||
// Close the popup.
|
||||
await UrlbarTestUtils.exitSearchMode(win);
|
||||
await UrlbarTestUtils.promisePopupClose(win);
|
||||
|
||||
// Hitting ESC should reshow the in-content search
|
||||
|
@ -137,8 +143,8 @@ add_task(async function test_search_handoff_on_keydown() {
|
|||
ok(
|
||||
!content.document
|
||||
.getElementById("search-handoff-button")
|
||||
.classList.contains("disabled"),
|
||||
"in-content search is not disabled"
|
||||
.classList.contains("hidden"),
|
||||
"in-content search is not hidden"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -154,11 +160,11 @@ add_task(async function test_search_handoff_on_composition_start() {
|
|||
await SpecialPowers.spawn(tab, [], async function() {
|
||||
content.document.getElementById("search-handoff-button").click();
|
||||
});
|
||||
ok(urlBarHasHiddenFocus(win), "Urlbar has hidden focus");
|
||||
ok(urlBarHasHiddenFocus(win), "url bar has hidden focused");
|
||||
await new Promise(r =>
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, win, r)
|
||||
);
|
||||
ok(urlBarHasNormalFocus(win), "Urlbar has normal focus");
|
||||
ok(urlBarHasNormalFocus(win), "url bar has normal focused");
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
@ -172,7 +178,7 @@ add_task(async function test_search_handoff_on_paste() {
|
|||
await SpecialPowers.spawn(tab, [], async function() {
|
||||
content.document.getElementById("search-handoff-button").click();
|
||||
});
|
||||
ok(urlBarHasHiddenFocus(win), "Urlbar has hidden focus");
|
||||
ok(urlBarHasHiddenFocus(win), "url bar has hidden focused");
|
||||
var helper = SpecialPowers.Cc[
|
||||
"@mozilla.org/widget/clipboardhelper;1"
|
||||
].getService(SpecialPowers.Ci.nsIClipboardHelper);
|
||||
|
@ -188,8 +194,13 @@ add_task(async function test_search_handoff_on_paste() {
|
|||
|
||||
await searchPromise;
|
||||
|
||||
ok(urlBarHasNormalFocus(win), "Urlbar has normal focus");
|
||||
is(win.gURLBar.value, "words", "Urlbar has search text");
|
||||
ok(urlBarHasNormalFocus(win), "url bar has normal focused");
|
||||
await UrlbarTestUtils.assertSearchMode(win, {
|
||||
engineName: "DuckDuckGo",
|
||||
source: UrlbarUtils.RESULT_SOURCE.SEARCH,
|
||||
entry: "handoff",
|
||||
});
|
||||
is(win.gURLBar.value, "words", "url bar has search text");
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
|
|
@ -20,29 +20,24 @@ ContentSearchHandoffUIController.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
get defaultEngine() {
|
||||
return this._defaultEngine;
|
||||
},
|
||||
|
||||
_onMsgEngine({ isPrivateWindow, engine }) {
|
||||
this._isPrivateWindow = isPrivateWindow;
|
||||
this._updateEngine(engine);
|
||||
this._updateEngineIcon(engine);
|
||||
},
|
||||
|
||||
_onMsgCurrentEngine(engine) {
|
||||
if (!this._isPrivateWindow) {
|
||||
this._updateEngine(engine);
|
||||
this._updateEngineIcon(engine);
|
||||
}
|
||||
},
|
||||
|
||||
_onMsgCurrentPrivateEngine(engine) {
|
||||
if (this._isPrivateWindow) {
|
||||
this._updateEngine(engine);
|
||||
this._updateEngineIcon(engine);
|
||||
}
|
||||
},
|
||||
|
||||
_updateEngine(engine) {
|
||||
this._defaultEngine = engine;
|
||||
_updateEngineIcon(engine) {
|
||||
if (this._engineIcon) {
|
||||
URL.revokeObjectURL(this._engineIcon);
|
||||
}
|
||||
|
@ -61,42 +56,6 @@ ContentSearchHandoffUIController.prototype = {
|
|||
"--newtab-search-icon",
|
||||
"url(" + this._engineIcon + ")"
|
||||
);
|
||||
|
||||
let fakeButton = document.querySelector(".search-handoff-button");
|
||||
let fakeInput = document.querySelector(".fake-textbox");
|
||||
if (!engine.isAppProvided) {
|
||||
document.l10n.setAttributes(
|
||||
fakeButton,
|
||||
this._isPrivateWindow
|
||||
? "about-private-browsing-handoff-no-engine"
|
||||
: "newtab-search-box-handoff-input-no-engine"
|
||||
);
|
||||
document.l10n.setAttributes(
|
||||
fakeInput,
|
||||
this._isPrivateWindow
|
||||
? "about-private-browsing-handoff-text-no-engine"
|
||||
: "newtab-search-box-handoff-text-no-engine"
|
||||
);
|
||||
} else {
|
||||
document.l10n.setAttributes(
|
||||
fakeButton,
|
||||
this._isPrivateWindow
|
||||
? "about-private-browsing-handoff"
|
||||
: "newtab-search-box-handoff-input",
|
||||
{
|
||||
engine: engine.name,
|
||||
}
|
||||
);
|
||||
document.l10n.setAttributes(
|
||||
fakeInput,
|
||||
this._isPrivateWindow
|
||||
? "about-private-browsing-handoff-text"
|
||||
: "newtab-search-box-handoff-text",
|
||||
{
|
||||
engine: engine.name,
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
// If the favicon is an array buffer, convert it into a Blob URI.
|
||||
|
|
|
@ -27,6 +27,8 @@ add_task(async function setup() {
|
|||
});
|
||||
});
|
||||
|
||||
// async function runAboutNewTabTest(expectedIcon)
|
||||
|
||||
async function ensureIcon(tab, expectedIcon) {
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [expectedIcon], async function(
|
||||
icon
|
||||
|
@ -47,29 +49,7 @@ async function ensureIcon(tab, expectedIcon) {
|
|||
});
|
||||
}
|
||||
|
||||
async function ensurePlaceholder(tab, expectedId, expectedEngine) {
|
||||
await SpecialPowers.spawn(
|
||||
tab.linkedBrowser,
|
||||
[expectedId, expectedEngine],
|
||||
async function(id, engine) {
|
||||
await ContentTaskUtils.waitForCondition(() => !content.document.hidden);
|
||||
|
||||
await ContentTaskUtils.waitForCondition(
|
||||
() => content.document.querySelector(".search-handoff-button"),
|
||||
"l10n ID not set."
|
||||
);
|
||||
let buttonNode = content.document.querySelector(".search-handoff-button");
|
||||
let expectedAttributes = { id, args: engine ? { engine } : null };
|
||||
Assert.deepEqual(
|
||||
content.document.l10n.getAttributes(buttonNode),
|
||||
expectedAttributes,
|
||||
"Expected updated l10n ID and args."
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function runNewTabTest(isHandoff) {
|
||||
async function runNewTabTest() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab({
|
||||
url: "about:newtab",
|
||||
gBrowser,
|
||||
|
@ -79,45 +59,35 @@ async function runNewTabTest(isHandoff) {
|
|||
let engineIcon = defaultEngine.getIconURLBySize(16, 16);
|
||||
|
||||
await ensureIcon(tab, engineIcon);
|
||||
if (isHandoff) {
|
||||
await ensurePlaceholder(
|
||||
tab,
|
||||
"newtab-search-box-handoff-input",
|
||||
Services.search.defaultEngine.name
|
||||
);
|
||||
}
|
||||
|
||||
await Services.search.setDefault(addedEngine);
|
||||
|
||||
// We only show the engine's own icon for app provided engines, otherwise show
|
||||
// a default. xref https://bugzilla.mozilla.org/show_bug.cgi?id=1449338#c19
|
||||
await ensureIcon(tab, "chrome://global/skin/icons/search-glass.svg");
|
||||
if (isHandoff) {
|
||||
await ensurePlaceholder(tab, "newtab-search-box-handoff-input-no-engine");
|
||||
}
|
||||
|
||||
await Services.search.setDefault(defaultEngine);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(async function test_content_search_attributes() {
|
||||
add_task(async function test_content_search_icon() {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [[HANDOFF_PREF, true]],
|
||||
});
|
||||
|
||||
await runNewTabTest(true);
|
||||
await runNewTabTest();
|
||||
});
|
||||
|
||||
add_task(async function test_content_search_attributes_no_handoff() {
|
||||
add_task(async function test_content_search_icon_no_handoff() {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [[HANDOFF_PREF, false]],
|
||||
});
|
||||
|
||||
await runNewTabTest(false);
|
||||
await runNewTabTest();
|
||||
});
|
||||
|
||||
add_task(async function test_content_search_attributes_in_private_window() {
|
||||
add_task(async function test_content_search_icon_in_private_window() {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow({
|
||||
private: true,
|
||||
waitForTabURL: "about:privatebrowsing",
|
||||
|
@ -127,18 +97,12 @@ add_task(async function test_content_search_attributes_in_private_window() {
|
|||
let engineIcon = defaultEngine.getIconURLBySize(16, 16);
|
||||
|
||||
await ensureIcon(tab, engineIcon);
|
||||
await ensurePlaceholder(
|
||||
tab,
|
||||
"about-private-browsing-handoff",
|
||||
Services.search.defaultEngine.name
|
||||
);
|
||||
|
||||
await Services.search.setDefault(addedEngine);
|
||||
|
||||
// We only show the engine's own icon for app provided engines, otherwise show
|
||||
// a default. xref https://bugzilla.mozilla.org/show_bug.cgi?id=1449338#c19
|
||||
await ensureIcon(tab, "chrome://global/skin/icons/search-glass.svg");
|
||||
await ensurePlaceholder(tab, "about-private-browsing-handoff-no-engine");
|
||||
|
||||
await Services.search.setDefault(defaultEngine);
|
||||
|
||||
|
|
|
@ -209,6 +209,7 @@ var UrlbarUtils = {
|
|||
// telemetry documentation and Scalars.yaml.
|
||||
SEARCH_MODE_ENTRY: new Set([
|
||||
"bookmarkmenu",
|
||||
"handoff",
|
||||
"keywordoffer",
|
||||
"oneoff",
|
||||
"other",
|
||||
|
|
|
@ -135,8 +135,7 @@ urlbar.searchmode.*
|
|||
menu.
|
||||
- ``handoff``
|
||||
Used when the user uses the search box on the new tab page and is handed off
|
||||
to the address bar. NOTE: This entry point was deprecated in Firefox 88.
|
||||
Handoff no longer enters search mode.
|
||||
to the address bar.
|
||||
- ``keywordoffer``
|
||||
Used when the user selects a keyword offer result.
|
||||
- ``oneoff``
|
||||
|
|
|
@ -191,14 +191,14 @@ add_task(async function searchWithAlias() {
|
|||
await UrlbarTestUtils.promisePopupOpen(window, async () =>
|
||||
gURLBar.search(`${ALIAS} test`, {
|
||||
searchEngine: aliasEngine,
|
||||
searchModeEntry: "topsites_urlbar",
|
||||
searchModeEntry: "handoff",
|
||||
})
|
||||
);
|
||||
Assert.ok(gURLBar.hasAttribute("focused"), "Urlbar is focused");
|
||||
|
||||
await UrlbarTestUtils.assertSearchMode(window, {
|
||||
engineName: aliasEngine.name,
|
||||
entry: "topsites_urlbar",
|
||||
entry: "handoff",
|
||||
});
|
||||
await assertUrlbarValue("test");
|
||||
assertOneOffButtonsVisible(true);
|
||||
|
|
|
@ -392,6 +392,39 @@ add_task(async function test_tabmenu() {
|
|||
assertSearchModeScalars("tabmenu", "tabs");
|
||||
});
|
||||
|
||||
// Enters search mode by performing a search handoff on about:privatebrowsing.
|
||||
// NOTE: We don't test handoff on about:home. Running mochitests on about:home
|
||||
// is quite difficult. This subtest verifies that `handoff` is a valid scalar
|
||||
// suffix and that a call to
|
||||
// UrlbarInput.search(value, { searchEngine, searchModeEntry: "handoff" }) records values in
|
||||
// the urlbar.searchmode.handoff scalar. PlacesFeed.test.js verfies that
|
||||
// about:home handoff makes that exact call.
|
||||
add_task(async function test_handoff_pbm() {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow({
|
||||
private: true,
|
||||
waitForTabURL: "about:privatebrowsing",
|
||||
});
|
||||
let tab = win.gBrowser.selectedBrowser;
|
||||
|
||||
await SpecialPowers.spawn(tab, [], async function() {
|
||||
let btn = content.document.getElementById("search-handoff-button");
|
||||
btn.click();
|
||||
});
|
||||
|
||||
let searchPromise = UrlbarTestUtils.promiseSearchComplete(win);
|
||||
await new Promise(r => EventUtils.synthesizeKey("f", {}, win, r));
|
||||
await searchPromise;
|
||||
await UrlbarTestUtils.assertSearchMode(win, {
|
||||
engineName,
|
||||
entry: "handoff",
|
||||
});
|
||||
assertSearchModeScalars("handoff", "other");
|
||||
|
||||
await UrlbarTestUtils.exitSearchMode(win);
|
||||
await UrlbarTestUtils.promisePopupClose(win);
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
// Enters search mode by tapping a search shortcut on the Touch Bar.
|
||||
add_task(async function test_touchbar() {
|
||||
if (AppConstants.platform != "macosx") {
|
||||
|
|
|
@ -4,18 +4,11 @@
|
|||
|
||||
privatebrowsingpage-open-private-window-label = Open a Private Window
|
||||
.accesskey = P
|
||||
about-private-browsing-search-placeholder = Search the Web
|
||||
about-private-browsing-info-title = You’re in a Private Window
|
||||
about-private-browsing-info-myths = Common myths about private browsing
|
||||
# Variables
|
||||
# $engine (String): the name of the user's default search engine
|
||||
about-private-browsing-handoff =
|
||||
.title = Search with { $engine } or enter address
|
||||
about-private-browsing-handoff-no-engine =
|
||||
.title = Search or enter address
|
||||
# Variables
|
||||
# $engine (String): the name of the user's default search engine
|
||||
about-private-browsing-handoff-text = Search with { $engine } or enter address
|
||||
about-private-browsing-handoff-text-no-engine = Search or enter address
|
||||
about-private-browsing =
|
||||
.title = Search the Web
|
||||
about-private-browsing-not-private = You are currently not in a private window.
|
||||
about-private-browsing-info-description = { -brand-short-name } clears your search and browsing history when you quit the app or close all Private Browsing tabs and windows. While this doesn’t make you anonymous to websites or your internet service provider, it makes it easier to keep what you do online private from anyone else who uses this computer.
|
||||
|
||||
|
|
|
@ -18,26 +18,13 @@ newtab-search-box-search-button =
|
|||
.title = Search
|
||||
.aria-label = Search
|
||||
|
||||
# Variables
|
||||
# $engine (String): the name of the user's default search engine
|
||||
newtab-search-box-handoff-text = Search with { $engine } or enter address
|
||||
newtab-search-box-handoff-text-no-engine = Search or enter address
|
||||
# Variables
|
||||
# $engine (String): the name of the user's default search engine
|
||||
newtab-search-box-handoff-input =
|
||||
.placeholder = Search with { $engine } or enter address
|
||||
.title = Search with { $engine } or enter address
|
||||
.aria-label = Search with { $engine } or enter address
|
||||
newtab-search-box-handoff-input-no-engine =
|
||||
.placeholder = Search or enter address
|
||||
.title = Search or enter address
|
||||
.aria-label = Search or enter address
|
||||
|
||||
newtab-search-box-search-the-web-text = Search the Web
|
||||
newtab-search-box-search-the-web-input =
|
||||
.placeholder = Search the Web
|
||||
.title = Search the Web
|
||||
.aria-label = Search the Web
|
||||
|
||||
newtab-search-box-text = Search the web
|
||||
newtab-search-box-input =
|
||||
.placeholder = Search the web
|
||||
.aria-label = Search the web
|
||||
|
|
|
@ -101,19 +101,20 @@ p {
|
|||
padding-inline: 46px 48px;
|
||||
position: relative;
|
||||
opacity: 1;
|
||||
transition: opacity 500ms;
|
||||
width: 100%;
|
||||
-moz-context-properties: fill;
|
||||
fill: rgba(12, 12, 13, 0.4);
|
||||
}
|
||||
|
||||
.search-handoff-button.focused:not(.disabled) {
|
||||
.search-handoff-button.focused {
|
||||
border: solid 1px #0060df;
|
||||
box-shadow: 0 0 0 1px #0060df, 0 0 0 4px rgba(0, 96, 223, 0.3);
|
||||
}
|
||||
|
||||
.search-handoff-button.disabled {
|
||||
opacity: 0.5;
|
||||
box-shadow: none;
|
||||
.search-handoff-button.hidden {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.search-handoff-button:dir(rtl),
|
||||
|
@ -126,7 +127,7 @@ p {
|
|||
background-color: #fff;
|
||||
}
|
||||
|
||||
.search-handoff-button.focused:not(.disabled) .fake-caret {
|
||||
.search-handoff-button.focused .fake-caret {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,11 +124,7 @@ let RemotePageAccessManager = {
|
|||
"OpenSearchPreferences",
|
||||
"SearchHandoff",
|
||||
],
|
||||
RPMSendQuery: [
|
||||
"ShouldShowSearch",
|
||||
"ShouldShowSearchBanner",
|
||||
"ShouldShowVPNPromo",
|
||||
],
|
||||
RPMSendQuery: ["ShouldShowSearchBanner", "ShouldShowVPNPromo"],
|
||||
RPMAddMessageListener: ["*"],
|
||||
RPMRemoveMessageListener: ["*"],
|
||||
RPMGetFormatURLPref: [
|
||||
|
|
Загрузка…
Ссылка в новой задаче