Backed out 2 changesets (bug 1776609) for causing gtest failures. CLOSED TREE

Backed out changeset 7630fea97777 (bug 1776609)
Backed out changeset 426cbe0fac73 (bug 1776609)
This commit is contained in:
Butkovits Atila 2022-07-29 13:42:33 +03:00
Родитель 6177804447
Коммит 900cbd85bd
31 изменённых файлов: 32 добавлений и 899 удалений

Просмотреть файл

@ -115,12 +115,6 @@ class ClickHandlerParent extends JSWindowActorParent {
openerBrowser: browser,
// The child ensures that untrusted events have a valid user activation.
hasValidUserGestureActivation: true,
globalHistoryOptions: {
triggeringSponsoredURL: browser.getAttribute("triggeringSponsoredURL"),
triggeringSponsoredURLVisitTimeMS: browser.getAttribute(
"triggeringSponsoredURLVisitTimeMS"
),
},
};
// The new tab/window must use the same userContextId.

Просмотреть файл

@ -1470,7 +1470,6 @@ function _loadURI(browser, uri, params = {}) {
csp,
remoteTypeOverride,
hasValidUserGestureActivation,
globalHistoryOptions,
} = params || {};
let loadFlags =
params.loadFlags || params.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
@ -1510,17 +1509,6 @@ function _loadURI(browser, uri, params = {}) {
// XXX(nika): Is `browser.isNavigating` necessary anymore?
browser.isNavigating = true;
if (globalHistoryOptions?.triggeringSponsoredURL) {
browser.setAttribute(
"triggeringSponsoredURL",
globalHistoryOptions.triggeringSponsoredURL
);
const time =
globalHistoryOptions.triggeringSponsoredURLVisitTimeMS || Date.now();
browser.setAttribute("triggeringSponsoredURLVisitTimeMS", time);
}
let loadURIOptions = {
triggeringPrincipal,
csp,

Просмотреть файл

@ -1405,14 +1405,6 @@ class nsContextMenu {
openLinkInTab(event) {
let params = {
userContextId: parseInt(event.target.getAttribute("data-usercontextid")),
globalHistoryOptions: {
triggeringSponsoredURL: this.browser.getAttribute(
"triggeringSponsoredURL"
),
triggeringSponsoredURLVisitTimeMS: this.browser.getAttribute(
"triggeringSponsoredURLVisitTimeMS"
),
},
};
openLinkIn(this.linkURL, "tab", this._openLinkInParameters(params));

Просмотреть файл

@ -1660,7 +1660,6 @@
var aName;
var aCsp;
var aSkipLoad;
var aGlobalHistoryOptions;
if (
arguments.length == 2 &&
typeof arguments[1] == "object" &&
@ -1690,7 +1689,6 @@
aName = params.name;
aCsp = params.csp;
aSkipLoad = params.skipLoad;
aGlobalHistoryOptions = params.globalHistoryOptions;
}
// all callers of loadOneTab need to pass a valid triggeringPrincipal.
@ -1730,7 +1728,6 @@
name: aName,
csp: aCsp,
skipLoad: aSkipLoad,
globalHistoryOptions: aGlobalHistoryOptions,
});
if (!bgLoad) {
this.selectedTab = tab;
@ -2588,7 +2585,6 @@
csp,
skipLoad,
batchInsertingTabs,
globalHistoryOptions,
} = {}
) {
// all callers of addTab that pass a params object need to pass
@ -2920,7 +2916,6 @@
charset,
postData,
csp,
globalHistoryOptions,
});
} catch (ex) {
Cu.reportError(ex);

Просмотреть файл

@ -307,7 +307,6 @@ function openLinkIn(url, where, params) {
var aResolveOnNewTabCreated = params.resolveOnNewTabCreated;
// This callback will be called with the content browser once it's created.
var aResolveOnContentBrowserReady = params.resolveOnContentBrowserCreated;
var aGlobalHistoryOptions = params.globalHistoryOptions;
if (!aTriggeringPrincipal) {
throw new Error("Must load with a triggering Principal");
@ -609,7 +608,6 @@ function openLinkIn(url, where, params) {
postData: aPostData,
userContextId: aUserContextId,
hasValidUserGestureActivation: params.hasValidUserGestureActivation,
globalHistoryOptions: aGlobalHistoryOptions,
});
if (aResolveOnContentBrowserReady) {
aResolveOnContentBrowserReady(targetBrowser);
@ -647,7 +645,6 @@ function openLinkIn(url, where, params) {
focusUrlBar,
openerBrowser: params.openerBrowser,
fromExternal: params.fromExternal,
globalHistoryOptions: aGlobalHistoryOptions,
});
targetBrowser = tabUsedForLoad.linkedBrowser;

Просмотреть файл

@ -279,11 +279,6 @@ class PlacesFeed {
private: isPrivate,
targetBrowser: action._target.browser,
fromChrome: false, // This ensure we maintain user preference for how to open new tabs.
globalHistoryOptions: {
triggeringSponsoredURL: action.data.sponsored_tile_id
? action.data.url
: undefined,
},
};
// Always include the referrer (even for http links) if we have one

Просмотреть файл

@ -1,2 +0,0 @@
first
<a href="annotation_second.html">goto second</a>

Просмотреть файл

@ -1,2 +0,0 @@
second
<a href="https://www.example.com/browser/browser/components/newtab/test/browser/annotation_third.html">goto third</a>

Просмотреть файл

@ -1,2 +0,0 @@
thrid
<a href="https://example.org/">goto outside</a>

Просмотреть файл

@ -2,11 +2,7 @@
support-files =
blue_page.html
red_page.html
annotation_first.html
annotation_second.html
annotation_third.html
head.js
redirect_to.sjs
snippet.json
snippet_below_search_test.json
snippet_simple_test.json
@ -66,7 +62,6 @@ support-files=
[browser_open_tab_focus.js]
skip-if = (os == "linux") # Test setup only implemented for OSX and Windows
[browser_remote_l10n.js]
[browser_topsites_annotation.js]
[browser_topsites_contextMenu_options.js]
[browser_topsites_section.js]
skip-if =

Просмотреть файл

@ -1,452 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test whether a visit information is annotated correctly when clicking a tile.
if (AppConstants.platform === "macosx") {
requestLongerTimeout(2);
}
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
NewTabUtils: "resource://gre/modules/NewTabUtils.jsm",
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.jsm",
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.jsm",
});
const OPEN_TYPE = {
CURRENT_BY_CLICK: 0,
NEWTAB_BY_CLICK: 1,
NEWTAB_BY_CONTEXTMENU: 2,
};
const { VISIT_SOURCE_ORGANIC, VISIT_SOURCE_SPONSORED } = PlacesUtils.history;
async function assertDatabase({ targetURL, expected }) {
const placesId = await PlacesTestUtils.fieldInDB(targetURL, "id");
const expectedTriggeringPlaceId = expected.triggerURL
? await PlacesTestUtils.fieldInDB(expected.triggerURL, "id")
: null;
const db = await PlacesUtils.promiseDBConnection();
const rows = await db.execute(
"SELECT source, triggeringPlaceId FROM moz_historyvisits WHERE place_id = :place_id AND source = :source",
{
place_id: placesId,
source: expected.source,
}
);
Assert.equal(rows.length, 1);
Assert.equal(
rows[0].getResultByName("triggeringPlaceId"),
expectedTriggeringPlaceId,
`The triggeringPlaceId in database is correct for ${targetURL}`
);
}
async function openAndTest({
linkSelector,
linkURL,
redirectTo = null,
openType = OPEN_TYPE.CURRENT_BY_CLICK,
expected,
}) {
const destinationURL = redirectTo || linkURL;
info("Open specific link and wait for loading.");
const isNewTab = openType !== OPEN_TYPE.CURRENT_BY_CLICK;
const onLoad = isNewTab
? BrowserTestUtils.waitForNewTab(gBrowser, destinationURL, true)
: BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
destinationURL
);
// If nodeIconChanged of browserPlacesViews.js is called after the target node
// is lost during test, "No DOM node set for aPlacesNode" error occur. To avoid
// this failure, wait for the onLocationChange event that triggers
// nodeIconChanged to occur.
const onLocationChanged = new Promise(resolve => {
gBrowser.addTabsProgressListener({
async onLocationChange(aBrowser, aWebProgress, aRequest, aLocation) {
if (aLocation.spec === destinationURL) {
gBrowser.removeTabsProgressListener(this);
// Wait for an empty Promise to ensure to proceed our test after
// finishing the processing of other onLocatoinChanged events.
await Promise.resolve();
resolve();
}
},
});
});
// Wait for content is ready.
await SpecialPowers.spawn(
gBrowser.selectedBrowser,
[linkSelector, linkURL],
async (selector, link) => {
await ContentTaskUtils.waitForCondition(
() => content.document.querySelector(selector).href === link
);
}
);
// Open the link by type.
if (openType === OPEN_TYPE.NEWTAB_BY_CLICK) {
await BrowserTestUtils.synthesizeMouseAtCenter(
linkSelector,
{ ctrlKey: isNewTab, metaKey: isNewTab },
gBrowser.selectedBrowser
);
} else if (openType === OPEN_TYPE.NEWTAB_BY_CONTEXTMENU) {
const onPopup = BrowserTestUtils.waitForEvent(document, "popupshown");
await BrowserTestUtils.synthesizeMouseAtCenter(
linkSelector,
{ type: "contextmenu" },
gBrowser.selectedBrowser
);
await onPopup;
const contextMenu = document.getElementById("contentAreaContextMenu");
const openLinkMenuItem = contextMenu.querySelector(
"#context-openlinkintab"
);
openLinkMenuItem.click();
contextMenu.hidePopup();
} else {
await BrowserTestUtils.synthesizeMouseAtCenter(
linkSelector,
{},
gBrowser.selectedBrowser
);
}
const maybeNewTab = await onLoad;
await onLocationChanged;
if (isNewTab) {
BrowserTestUtils.removeTab(maybeNewTab);
}
info("Check database for the destination.");
await assertDatabase({ targetURL: destinationURL, expected });
}
async function pin(link) {
// Setup test tile.
NewTabUtils.pinnedLinks.pin(link, 0);
await toggleTopsitesPref();
await BrowserTestUtils.waitForCondition(() => {
const sites = AboutNewTab.getTopSites();
return (
sites?.[0]?.url === link.url &&
sites[0].sponsored_tile_id === link.sponsored_tile_id
);
}, "Waiting for top sites to be updated");
}
function unpin(link) {
NewTabUtils.pinnedLinks.unpin(link);
}
add_setup(async function() {
await clearHistoryAndBookmarks();
registerCleanupFunction(async () => {
await clearHistoryAndBookmarks();
});
});
add_task(async function basic() {
const testData = [
{
description: "Sponsored tile",
link: {
label: "test_label",
url: "http://example.com/",
sponsored_position: 1,
sponsored_tile_id: 12345,
sponsored_impression_url: "http://impression.example.com/",
sponsored_click_url: "http://click.example.com/",
},
expected: {
source: VISIT_SOURCE_SPONSORED,
},
},
{
description: "Organic tile",
link: {
label: "test_label",
url: "http://example.com/",
},
expected: {
source: VISIT_SOURCE_ORGANIC,
},
},
];
for (const { description, link, expected } of testData) {
info(description);
await BrowserTestUtils.withNewTab("about:home", async () => {
// Setup test tile.
await pin(link);
// Test with new tab.
await openAndTest({
linkSelector: ".top-site-button",
linkURL: link.url,
openType: OPEN_TYPE.NEWTAB_BY_CLICK,
expected,
});
await clearHistoryAndBookmarks();
// Test with same tab.
await openAndTest({
linkSelector: ".top-site-button",
linkURL: link.url,
expected,
});
await clearHistoryAndBookmarks();
unpin(link);
});
}
});
add_task(async function redirection() {
await BrowserTestUtils.withNewTab("about:home", async () => {
const redirectTo = "http://example.com/";
const link = {
label: "test_label",
url:
"http://example.com/browser/browser/components/newtab/test/browser/redirect_to.sjs?/",
sponsored_position: 1,
sponsored_tile_id: 12345,
sponsored_impression_url: "http://impression.example.com/",
sponsored_click_url: "http://click.example.com/",
};
// Setup test tile.
await pin(link);
// Test with new tab.
await openAndTest({
linkSelector: ".top-site-button",
linkURL: link.url,
redirectTo,
openType: OPEN_TYPE.NEWTAB_BY_CLICK,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
// Check for URL causes the redirection.
await assertDatabase({
targetURL: link.url,
expected: {
source: VISIT_SOURCE_SPONSORED,
},
});
await clearHistoryAndBookmarks();
// Test with same tab.
await openAndTest({
linkSelector: ".top-site-button",
linkURL: link.url,
redirectTo,
openType: OPEN_TYPE.NEWTAB_BY_CLICK,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
// Check for URL causes the redirection.
await assertDatabase({
targetURL: link.url,
expected: {
source: VISIT_SOURCE_SPONSORED,
},
});
await clearHistoryAndBookmarks();
unpin(link);
});
});
add_task(async function inherit() {
const host = "https://example.com/";
const sameBaseDomainHost = "https://www.example.com/";
const path = "browser/browser/components/newtab/test/browser/";
const firstURL = `${host}${path}annotation_first.html`;
const secondURL = `${host}${path}annotation_second.html`;
const thirdURL = `${sameBaseDomainHost}${path}annotation_third.html`;
const outsideURL = "https://example.org/";
await BrowserTestUtils.withNewTab("about:home", async () => {
const link = {
label: "first",
url: firstURL,
sponsored_position: 1,
sponsored_tile_id: 12345,
sponsored_impression_url: "http://impression.example.com/",
sponsored_click_url: "http://click.example.com/",
};
// Setup test tile.
await pin(link);
info("Open the tile to show first page in same tab");
await openAndTest({
linkSelector: ".top-site-button",
linkURL: link.url,
expected: {
source: VISIT_SOURCE_SPONSORED,
},
});
info("Open link on first page to show second page in new tab");
await openAndTest({
linkSelector: "a",
linkURL: secondURL,
openType: OPEN_TYPE.NEWTAB_BY_CLICK,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
await PlacesTestUtils.clearHistoryVisits();
info("Open link on first page to show second page in same tab");
await openAndTest({
linkSelector: "a",
linkURL: secondURL,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
info(
"Open link on second page to show third page in new tab by context menu"
);
await openAndTest({
linkSelector: "a",
linkURL: thirdURL,
openType: OPEN_TYPE.NEWTAB_BY_CONTEXTMENU,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
await PlacesTestUtils.clearHistoryVisits();
info("Open link on second page to show third page in same tab");
await openAndTest({
linkSelector: "a",
linkURL: thirdURL,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
info("Open link on third page to show outside domain page in same tab");
await openAndTest({
linkSelector: "a",
linkURL: outsideURL,
expected: {
source: VISIT_SOURCE_ORGANIC,
},
});
info("Visit URL that has the same domain as sponsored link from URL bar");
const onLoad = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
host
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: host,
waitForFocus: SimpleTest.waitForFocus,
});
EventUtils.synthesizeKey("KEY_Enter");
await onLoad;
await assertDatabase({
targetURL: host,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: link.url,
},
});
unpin(link);
await clearHistoryAndBookmarks();
});
});
add_task(async function timeout() {
const base =
"https://example.com/browser/browser/components/newtab/test/browser";
const firstURL = `${base}/annotation_first.html`;
const secondURL = `${base}/annotation_second.html`;
await BrowserTestUtils.withNewTab("about:home", async () => {
info("Set timeout second");
await SpecialPowers.pushPrefEnv({
set: [["places.sponsoredSession.timeOutSec", 1]],
});
const link = {
label: "test",
url: firstURL,
sponsored_position: 1,
sponsored_tile_id: 12345,
sponsored_impression_url: "http://impression.example.com/",
sponsored_click_url: "http://click.example.com/",
};
// Setup a test tile.
await pin(link);
info("Open the tile");
await openAndTest({
linkSelector: ".top-site-button",
linkURL: link.url,
expected: {
source: VISIT_SOURCE_SPONSORED,
},
});
info("Wait 1 sec");
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
await new Promise(r => setTimeout(r, 1000));
info("Open link on first page to show second page in new tab");
await openAndTest({
linkSelector: "a",
linkURL: secondURL,
openType: OPEN_TYPE.NEWTAB_BY_CLICK,
expected: {
source: VISIT_SOURCE_ORGANIC,
},
});
await PlacesTestUtils.clearHistoryVisits();
info("Open link on first page to show second page");
await openAndTest({
linkSelector: "a",
linkURL: secondURL,
expected: {
source: VISIT_SOURCE_ORGANIC,
},
});
unpin(link);
await clearHistoryAndBookmarks();
});
});

Просмотреть файл

@ -1,9 +0,0 @@
"use strict";
function handleRequest(request, response) {
// redirect_to.sjs?ctxmenu-image.png
// redirects to : ctxmenu-image.png
const redirectUrl = request.queryString;
response.setStatusLine(request.httpVersion, "302", "Found");
response.setHeader("Location", redirectUrl, false);
}

Просмотреть файл

@ -802,11 +802,6 @@ export class UrlbarInput {
let where = this._whereToOpen(event);
let openParams = {
allowInheritPrincipal: false,
globalHistoryOptions: {
triggeringSponsoredURL: result.payload?.isSponsored
? result.payload.url
: undefined,
},
};
if (

Просмотреть файл

@ -302,9 +302,6 @@ https_first_disabled = true
[browser_unitConversion.js]
[browser_updateForDomainCompletion.js]
https_first_disabled = true
[browser_urlbar_annotation.js]
support-files =
redirect_to.sjs
[browser_urlbar_event_telemetry_abandonment.js]
support-files =
searchSuggestionEngine.xml

Просмотреть файл

@ -1,155 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test whether a visit information is annotated correctly when picking a result.
const { VISIT_SOURCE_ORGANIC, VISIT_SOURCE_SPONSORED } = PlacesUtils.history;
async function assertDatabase({ targetURL, expected }) {
const placesId = await PlacesTestUtils.fieldInDB(targetURL, "id");
const expectedTriggeringPlaceId = expected.triggerURL
? await PlacesTestUtils.fieldInDB(expected.triggerURL, "id")
: null;
const db = await PlacesUtils.promiseDBConnection();
const rows = await db.execute(
"SELECT source, triggeringPlaceId FROM moz_historyvisits WHERE place_id = :place_id AND source = :source",
{
place_id: placesId,
source: expected.source,
}
);
Assert.equal(rows.length, 1);
Assert.equal(
rows[0].getResultByName("triggeringPlaceId"),
expectedTriggeringPlaceId,
`The triggeringPlaceId in database is correct for ${targetURL}`
);
}
function registerProvider(payload) {
const provider = new UrlbarTestUtils.TestProvider({
results: [
new UrlbarResult(
UrlbarUtils.RESULT_TYPE.URL,
UrlbarUtils.RESULT_SOURCE.SEARCH,
...UrlbarResult.payloadAndSimpleHighlights([], {
...payload,
})
),
],
priority: Infinity,
});
UrlbarProvidersManager.registerProvider(provider);
return provider;
}
async function pickResult({ input, payloadURL, redirectTo }) {
const destinationURL = redirectTo || payloadURL;
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: input,
fireInputEvent: true,
});
const result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
Assert.equal(result.url, payloadURL);
UrlbarTestUtils.setSelectedRowIndex(window, 0);
info("Show result and wait for loading");
const onLoad = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
destinationURL
);
EventUtils.synthesizeKey("KEY_Enter");
await onLoad;
}
add_setup(async function() {
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
registerCleanupFunction(async () => {
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
});
});
add_task(async function basic() {
const testData = [
{
description: "Sponsored result",
input: "exa",
payload: {
url: "http://example.com/",
isSponsored: true,
},
expected: {
source: VISIT_SOURCE_SPONSORED,
},
},
{
description: "Organic result",
input: "exa",
payload: {
url: "http://example.com/",
},
expected: {
source: VISIT_SOURCE_ORGANIC,
},
},
];
for (const { description, input, payload, expected } of testData) {
info(description);
const provider = registerProvider(payload);
await BrowserTestUtils.withNewTab("about:blank", async () => {
info("Pick result");
await pickResult({ input, payloadURL: payload.url });
info("Check database");
await assertDatabase({ targetURL: payload.url, expected });
});
UrlbarProvidersManager.unregisterProvider(provider);
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
}
});
add_task(async function redirection() {
const redirectTo = "http://example.com/";
const payload = {
url:
"http://example.com/browser/browser/components/urlbar/tests/browser/redirect_to.sjs?/",
isSponsored: true,
};
const input = "exa";
const provider = registerProvider(payload);
await BrowserTestUtils.withNewTab("about:home", async () => {
info("Pick result");
await pickResult({ input, payloadURL: payload.url, redirectTo });
info("Check database");
await assertDatabase({
targetURL: payload.url,
expected: {
source: VISIT_SOURCE_SPONSORED,
},
});
await assertDatabase({
targetURL: redirectTo,
expected: {
source: VISIT_SOURCE_SPONSORED,
triggerURL: payload.url,
},
});
});
await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything();
UrlbarProvidersManager.unregisterProvider(provider);
});

Просмотреть файл

@ -1,9 +0,0 @@
"use strict";
function handleRequest(request, response) {
// redirect_to.sjs?ctxmenu-image.png
// redirects to : ctxmenu-image.png
const redirectUrl = request.queryString;
response.setStatusLine(request.httpVersion, "302", "Found");
response.setHeader("Location", redirectUrl, false);
}

Просмотреть файл

@ -214,17 +214,6 @@ const BrowserWindowTracker = {
return WindowHelper.addWindow(window);
},
getBrowserById(browserId) {
for (let win of BrowserWindowTracker.orderedWindows) {
for (let tab of win.gBrowser.visibleTabs) {
if (tab.linkedPanel && tab.linkedBrowser.browserId === browserId) {
return tab.linkedBrowser;
}
}
}
return null;
},
// For tests only, this function will remove this window from the list of
// tracked windows. Please don't forget to add it back at the end of your
// tests!

Просмотреть файл

@ -143,11 +143,9 @@ class IHistory : public nsISupports {
* The URI of the last visit in the chain.
* @param aFlags
* The VisitFlags describing this visit.
* @param aBrowserId
* The id of browser used for this visit.
*/
NS_IMETHOD VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
uint32_t aFlags, uint64_t aBrowserId) = 0;
uint32_t aFlags) = 0;
/**
* Set the title of the URI.

Просмотреть файл

@ -12374,8 +12374,7 @@ void nsDocShell::SaveLastVisit(nsIChannel* aChannel, nsIURI* aURI,
}
mozilla::Unused << history->VisitURI(aWidget, aURI, aPreviousURI,
visitURIFlags,
aBrowsingContext->BrowserId());
visitURIFlags);
}
}

Просмотреть файл

@ -3894,9 +3894,9 @@ mozilla::ipc::IPCResult BrowserParent::RecvShowCanvasPermissionPrompt(
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvVisitURI(
nsIURI* aURI, nsIURI* aLastVisitedURI, const uint32_t& aFlags,
const uint64_t& aBrowserId) {
mozilla::ipc::IPCResult BrowserParent::RecvVisitURI(nsIURI* aURI,
nsIURI* aLastVisitedURI,
const uint32_t& aFlags) {
if (!aURI) {
return IPC_FAIL_NO_REASON(this);
}
@ -3906,8 +3906,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvVisitURI(
}
nsCOMPtr<IHistory> history = components::History::Service();
if (history) {
Unused << history->VisitURI(widget, aURI, aLastVisitedURI, aFlags,
aBrowserId);
Unused << history->VisitURI(widget, aURI, aLastVisitedURI, aFlags);
}
return IPC_OK();
}

Просмотреть файл

@ -747,8 +747,7 @@ class BrowserParent final : public PBrowserParent,
mozilla::ipc::IPCResult RecvGetSystemFont(nsCString* aFontName);
mozilla::ipc::IPCResult RecvVisitURI(nsIURI* aURI, nsIURI* aLastVisitedURI,
const uint32_t& aFlags,
const uint64_t& aBrowserId);
const uint32_t& aFlags);
mozilla::ipc::IPCResult RecvQueryVisitedState(
nsTArray<RefPtr<nsIURI>>&& aURIs);

Просмотреть файл

@ -1010,7 +1010,8 @@ parent:
async IsWindowSupportingWebVR(uint64_t aOuterWindowID) returns(bool isSupported);
/** Records a history visit. */
async VisitURI(nsIURI aURI, nsIURI aLastVisitedURI, uint32_t aFlags, uint64_t aBrowserId);
async VisitURI(nsIURI aURI, nsIURI aLastVisitedURI,
uint32_t aFlags);
/** Fetches the visited status for an array of URIs (Android-only). */
async QueryVisitedState(nsIURI[] aURIs);

Просмотреть файл

@ -235,8 +235,7 @@ NS_IMPL_ISUPPORTS(OnVisitedCallback, nsIAndroidEventCallback)
NS_IMETHODIMP
GeckoViewHistory::VisitURI(nsIWidget* aWidget, nsIURI* aURI,
nsIURI* aLastVisitedURI, uint32_t aFlags,
uint64_t aBrowserId) {
nsIURI* aLastVisitedURI, uint32_t aFlags) {
if (!aURI) {
return NS_OK;
}
@ -253,7 +252,7 @@ GeckoViewHistory::VisitURI(nsIWidget* aWidget, nsIURI* aURI,
return NS_OK;
}
Unused << NS_WARN_IF(
!browserChild->SendVisitURI(aURI, aLastVisitedURI, aFlags, aBrowserId));
!browserChild->SendVisitURI(aURI, aLastVisitedURI, aFlags));
return NS_OK;
}

Просмотреть файл

@ -33,7 +33,7 @@ class GeckoViewHistory final : public mozilla::BaseHistory {
// IHistory
NS_IMETHOD VisitURI(nsIWidget*, nsIURI*, nsIURI* aLastVisitedURI,
uint32_t aFlags, uint64_t aBrowserId) final;
uint32_t aFlags) final;
NS_IMETHOD SetURITitle(nsIURI*, const nsAString&) final;
static already_AddRefed<GeckoViewHistory> GetSingleton();

Просмотреть файл

@ -34,7 +34,6 @@
#include "mozilla/Unused.h"
#include "nsContentUtils.h" // for nsAutoScriptBlocker
#include "nsJSUtils.h"
#include "nsStandardURL.h"
#include "mozilla/ipc/URIUtils.h"
#include "nsPrintfCString.h"
#include "nsTHashtable.h"
@ -49,9 +48,6 @@
#include "mozilla/dom/PlacesVisitTitle.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsIBrowserWindowTracker.h"
#include "nsImportModule.h"
using namespace mozilla::dom;
using namespace mozilla::ipc;
using mozilla::Unused;
@ -86,15 +82,9 @@ struct VisitData {
referrerVisitId(0),
titleChanged(false),
shouldUpdateFrecency(true),
useFrecencyRedirectBonus(false),
source(nsINavHistoryService::VISIT_SOURCE_ORGANIC),
triggeringPlaceId(0),
triggeringSponsoredURLVisitTimeMS(0) {
useFrecencyRedirectBonus(false) {
guid.SetIsVoid(true);
title.SetIsVoid(true);
baseDomain.SetIsVoid(true);
triggeringSponsoredURL.SetIsVoid(true);
triggeringSponsoredURLBaseDomain.SetIsVoid(true);
}
explicit VisitData(nsIURI* aURI, nsIURI* aReferrer = nullptr)
@ -112,10 +102,7 @@ struct VisitData {
referrerVisitId(0),
titleChanged(false),
shouldUpdateFrecency(true),
useFrecencyRedirectBonus(false),
source(nsINavHistoryService::VISIT_SOURCE_ORGANIC),
triggeringPlaceId(0),
triggeringSponsoredURLVisitTimeMS(0) {
useFrecencyRedirectBonus(false) {
MOZ_ASSERT(aURI);
if (aURI) {
(void)aURI->GetSpec(spec);
@ -126,9 +113,6 @@ struct VisitData {
}
guid.SetIsVoid(true);
title.SetIsVoid(true);
baseDomain.SetIsVoid(true);
triggeringSponsoredURL.SetIsVoid(true);
triggeringSponsoredURLBaseDomain.SetIsVoid(true);
}
/**
@ -147,7 +131,6 @@ struct VisitData {
nsCString guid;
int64_t visitId;
nsCString spec;
nsCString baseDomain;
nsString revHost;
bool hidden;
bool shouldUpdateHidden;
@ -179,12 +162,6 @@ struct VisitData {
// Whether to override the visit type bonus with a redirect bonus when
// calculating frecency on the most recent visit.
bool useFrecencyRedirectBonus;
uint16_t source;
int64_t triggeringPlaceId;
nsCString triggeringSponsoredURL;
nsCString triggeringSponsoredURLBaseDomain;
int64_t triggeringSponsoredURLVisitTimeMS;
};
////////////////////////////////////////////////////////////////////////////////
@ -926,7 +903,6 @@ class InsertVisitedURIs final : public Runnable {
}
FetchReferrerInfo(place);
UpdateVisitSource(place, mHistory);
nsresult rv = DoDatabaseInserts(known, place);
if (!!mCallback) {
@ -1021,11 +997,6 @@ class InsertVisitedURIs final : public Runnable {
"Passed a VisitData with a URI we cannot add to history!");
}
#endif
// Need to get session timeout pref here since static call for Preferences
// should run on main thread.
mSponsoredSessionTimeoutSec = Preferences::GetUint(
"places.sponsoredSession.timeOutSec", 3600 /* Default 1 hour */);
}
/**
@ -1122,10 +1093,8 @@ class InsertVisitedURIs final : public Runnable {
nsCOMPtr<mozIStorageStatement> stmt;
stmt = mHistory->GetStatement(
"INSERT INTO moz_historyvisits "
"(from_visit, place_id, visit_date, visit_type, session, source, "
"triggeringPlaceId) "
"VALUES (:from_visit, :page_id, :visit_date, :visit_type, 0, :source, "
":triggeringPlaceId) ");
"(from_visit, place_id, visit_date, visit_type, session) "
"VALUES (:from_visit, :page_id, :visit_date, :visit_type, 0) ");
NS_ENSURE_STATE(stmt);
mozStorageStatementScoper scoper(stmt);
@ -1141,15 +1110,6 @@ class InsertVisitedURIs final : public Runnable {
"Invalid transition type!");
rv = stmt->BindInt32ByName("visit_type"_ns, transitionType);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->BindInt32ByName("source"_ns, _place.source);
NS_ENSURE_SUCCESS(rv, rv);
if (_place.triggeringPlaceId != 0) {
rv = stmt->BindInt64ByName("triggeringPlaceId"_ns,
_place.triggeringPlaceId);
} else {
rv = stmt->BindNullByName("triggeringPlaceId"_ns);
}
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, rv);
@ -1209,59 +1169,6 @@ class InsertVisitedURIs final : public Runnable {
return NS_OK;
}
nsresult UpdateVisitSource(VisitData& aPlace, History* aHistory) {
aPlace.source = nsINavHistoryService::VISIT_SOURCE_ORGANIC;
if (aPlace.triggeringSponsoredURL.IsEmpty()) {
// No triggeringSponsoredURL.
return NS_OK;
}
if ((aPlace.visitTime -
aPlace.triggeringSponsoredURLVisitTimeMS * PR_USEC_PER_MSEC) >
mSponsoredSessionTimeoutSec * PR_USEC_PER_SEC) {
// Sponsored session timeout.
return NS_OK;
}
if (aPlace.spec.Equals(aPlace.triggeringSponsoredURL)) {
// This place is the triggeringSponsoredURL.
aPlace.source = nsINavHistoryService::VISIT_SOURCE_SPONSORED;
return NS_OK;
}
if (!aPlace.baseDomain.Equals(aPlace.triggeringSponsoredURLBaseDomain)) {
// The base domain is not same.
return NS_OK;
}
nsCOMPtr<mozIStorageStatement> stmt;
stmt = aHistory->GetStatement(
"SELECT id FROM moz_places h "
"WHERE url_hash = hash(:url) AND url = :url");
NS_ENSURE_STATE(stmt);
nsresult rv =
URIBinder::Bind(stmt, "url"_ns, aPlace.triggeringSponsoredURL);
NS_ENSURE_SUCCESS(rv, rv);
mozStorageStatementScoper scoper(stmt);
bool exists;
rv = stmt->ExecuteStep(&exists);
NS_ENSURE_SUCCESS(rv, rv);
if (!exists) {
// Not in sponsored session since no history.
return NS_OK;
}
rv = stmt->GetInt64(0, &aPlace.triggeringPlaceId);
NS_ENSURE_SUCCESS(rv, rv);
aPlace.source = nsINavHistoryService::VISIT_SOURCE_SPONSORED;
return NS_OK;
}
mozIStorageConnection* mDBConn;
nsTArray<VisitData> mPlaces;
@ -1274,8 +1181,6 @@ class InsertVisitedURIs final : public Runnable {
uint32_t mSuccessfulUpdatedCount;
uint32_t mSponsoredSessionTimeoutSec;
/**
* Strong reference to the History object because we do not want it to
* disappear out from under us.
@ -1862,7 +1767,7 @@ void History::AppendToRecentlyVisitedURIs(nsIURI* aURI, bool aHidden) {
NS_IMETHODIMP
History::VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
uint32_t aFlags, uint64_t aBrowserId) {
uint32_t aFlags) {
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_ARG(aURI);
@ -1870,6 +1775,7 @@ History::VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
return NS_OK;
}
nsresult rv;
if (XRE_IsContentProcess()) {
if (!BaseHistory::CanStore(aURI)) {
return NS_OK;
@ -1878,7 +1784,7 @@ History::VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
NS_ENSURE_ARG(aWidget);
BrowserChild* browserChild = aWidget->GetOwningBrowserChild();
NS_ENSURE_TRUE(browserChild, NS_ERROR_FAILURE);
(void)browserChild->SendVisitURI(aURI, aLastVisitedURI, aFlags, aBrowserId);
(void)browserChild->SendVisitURI(aURI, aLastVisitedURI, aFlags);
return NS_OK;
}
@ -1887,7 +1793,7 @@ History::VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
// Silently return if URI is something we shouldn't add to DB.
bool canAdd;
nsresult rv = navHistory->CanAddURI(aURI, &canAdd);
rv = navHistory->CanAddURI(aURI, &canAdd);
NS_ENSURE_SUCCESS(rv, rv);
if (!canAdd) {
return NS_OK;
@ -1974,47 +1880,6 @@ History::VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
}
}
nsCOMPtr<nsIBrowserWindowTracker> bwt =
do_ImportModule("resource:///modules/BrowserWindowTracker.jsm",
"BrowserWindowTracker", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> browser;
rv = bwt->GetBrowserById(aBrowserId, getter_AddRefs(browser));
NS_ENSURE_SUCCESS(rv, rv);
if (browser) {
RefPtr<Element> browserElement = static_cast<Element*>(browser.get());
nsAutoString triggeringSponsoredURL;
browserElement->GetAttribute(u"triggeringSponsoredURL"_ns,
triggeringSponsoredURL);
if (!triggeringSponsoredURL.IsEmpty()) {
place.triggeringSponsoredURL.Assign(
NS_ConvertUTF16toUTF8(triggeringSponsoredURL));
nsAutoString triggeringSponsoredURLVisitTimeMS;
browserElement->GetAttribute(u"triggeringSponsoredURLVisitTimeMS"_ns,
triggeringSponsoredURLVisitTimeMS);
place.triggeringSponsoredURLVisitTimeMS =
triggeringSponsoredURLVisitTimeMS.ToInteger64(&rv);
NS_ENSURE_SUCCESS(rv, rv);
// Get base domain. We need to get it here since nsIEffectiveTLDService
// referred in DomainNameFromURI should access on main thread.
nsCOMPtr<nsIURI> currentURL;
rv = NS_MutateURI(new net::nsStandardURL::Mutator())
.SetSpec(place.spec)
.Finalize(currentURL);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> sponsoredURL;
rv = NS_MutateURI(new net::nsStandardURL::Mutator())
.SetSpec(place.triggeringSponsoredURL)
.Finalize(sponsoredURL);
NS_ENSURE_SUCCESS(rv, rv);
navHistory->DomainNameFromURI(currentURL, place.baseDomain);
navHistory->DomainNameFromURI(sponsoredURL,
place.triggeringSponsoredURLBaseDomain);
}
}
// EMBED visits should not go through the database.
// They exist only to keep track of isVisited status during the session.
if (place.transitionType == nsINavHistoryService::TRANSITION_EMBED) {

Просмотреть файл

@ -57,7 +57,7 @@ class History final : public BaseHistory,
// IHistory
NS_IMETHOD VisitURI(nsIWidget*, nsIURI*, nsIURI* aLastVisitedURI,
uint32_t aFlags, uint64_t aBrowserId) final;
uint32_t aFlags) final;
NS_IMETHOD SetURITitle(nsIURI*, const nsAString&) final;
// BaseHistory

Просмотреть файл

@ -1022,16 +1022,6 @@ interface nsINavHistoryService : nsISupports
*/
const unsigned short DATABASE_STATUS_LOCKED = 4;
/**
* Insert this value into moz_historyvisits if the visit source is organic.
*/
const unsigned short VISIT_SOURCE_ORGANIC = 0;
/**
* Insert this value into moz_historyvisits if the visit source is sponsored.
*/
const unsigned short VISIT_SOURCE_SPONSORED = 1;
/**
* Returns the current database status
*/

Просмотреть файл

@ -526,18 +526,6 @@ export var PlacesTestUtils = Object.freeze({
);
},
/**
* Clear moz_historyvisits table.
*/
async clearHistoryVisits() {
await lazy.PlacesUtils.withConnectionWrapper(
"test:clearHistoryVisits",
db => {
return db.executeCached("DELETE FROM moz_historyvisits");
}
);
},
/**
* Compares 2 place: URLs ignoring the order of their params.
* @param url1 First URL to compare

Просмотреть файл

@ -304,8 +304,8 @@ void do_wait_async_updates() {
void addURI(nsIURI* aURI) {
nsCOMPtr<mozilla::IHistory> history = do_GetService(NS_IHISTORY_CONTRACTID);
do_check_true(history);
nsresult rv = history->VisitURI(nullptr, aURI, nullptr,
mozilla::IHistory::TOP_LEVEL, 0);
nsresult rv =
history->VisitURI(nullptr, aURI, nullptr, mozilla::IHistory::TOP_LEVEL);
do_check_success(rv);
do_wait_async_updates();

Просмотреть файл

@ -275,8 +275,7 @@ void test_visituri_inserts() {
nsCOMPtr<nsIURI> lastURI = new_test_uri();
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL,
0);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
finisher->WaitForNotification();
@ -298,13 +297,11 @@ void test_visituri_updates() {
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
RefPtr<VisitURIObserver> finisher;
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL,
0);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
finisher = new VisitURIObserver();
finisher->WaitForNotification();
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL,
0);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
finisher = new VisitURIObserver();
finisher->WaitForNotification();
@ -321,11 +318,10 @@ void test_visituri_preserves_shown_and_typed() {
nsCOMPtr<nsIURI> lastURI = new_test_uri();
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL,
0);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
// this simulates the uri visit happening in a frame. Normally frame
// transitions would be hidden unless it was previously loaded top-level
history->VisitURI(nullptr, visitedURI, lastURI, 0, 0);
history->VisitURI(nullptr, visitedURI, lastURI, 0);
RefPtr<VisitURIObserver> finisher = new VisitURIObserver(2);
finisher->WaitForNotification();
@ -342,8 +338,7 @@ void test_visituri_creates_visit() {
nsCOMPtr<nsIURI> lastURI = new_test_uri();
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL,
0);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
finisher->WaitForNotification();
@ -366,8 +361,7 @@ void test_visituri_transition_typed() {
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
navHistory->MarkPageAsTyped(visitedURI);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL,
0);
history->VisitURI(nullptr, visitedURI, lastURI, mozilla::IHistory::TOP_LEVEL);
RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
finisher->WaitForNotification();
@ -386,7 +380,7 @@ void test_visituri_transition_embed() {
nsCOMPtr<nsIURI> lastURI = new_test_uri();
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
history->VisitURI(nullptr, visitedURI, lastURI, 0, 0);
history->VisitURI(nullptr, visitedURI, lastURI, 0);
RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
finisher->WaitForNotification();
@ -406,7 +400,7 @@ void test_new_visit_adds_place_guid() {
nsCOMPtr<nsIURI> visitedURI = new_test_uri();
nsCOMPtr<IHistory> history = do_get_IHistory();
nsresult rv = history->VisitURI(nullptr, visitedURI, nullptr,
mozilla::IHistory::TOP_LEVEL, 0);
mozilla::IHistory::TOP_LEVEL);
do_check_success(rv);
RefPtr<VisitURIObserver> finisher = new VisitURIObserver();
finisher->WaitForNotification();

Просмотреть файл

@ -17,9 +17,4 @@ interface nsIBrowserWindowTracker : nsISupports
* Return array of browser tabs that are currently visible.
*/
Array<nsIVisibleTab> getAllVisibleTabs();
/**
* Return browser having given browser id.
*/
nsISupports getBrowserById(in uint64_t aBrowserId);
};