From 25458bec5023bf0eeca0f4165da351dd9527cfda Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Tue, 7 Jan 2014 12:59:18 -0800 Subject: [PATCH 1/5] Bug 809056 - Reduce thumbnailing impact by capturing and storing only top sites. r=markh --- browser/base/content/browser-thumbnails.js | 7 ++++++ .../test/browser_thumbnails_bug818225.js | 1 + .../test/browser_thumbnails_privacy.js | 8 +++++++ .../test/browser_thumbnails_storage.js | 2 ++ toolkit/components/thumbnails/test/head.js | 23 +++++++++++++++---- toolkit/modules/NewTabUtils.jsm | 2 +- 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/browser/base/content/browser-thumbnails.js b/browser/base/content/browser-thumbnails.js index e255dcc03ed..754b7cf587c 100644 --- a/browser/base/content/browser-thumbnails.js +++ b/browser/base/content/browser-thumbnails.js @@ -4,6 +4,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #endif +Cu.import("resource://gre/modules/NewTabUtils.jsm"); + /** * Keeps thumbnails of open web pages up-to-date. */ @@ -120,6 +122,11 @@ let gBrowserThumbnails = { }, _shouldCapture: function Thumbnails_shouldCapture(aBrowser) { + // Capture only if it's a top site in about:newtab. + if (!NewTabUtils.links.getLinks().some( + (link) => link.url == aBrowser.currentURI.spec)) + return false; + // Capture only if it's the currently selected tab. if (aBrowser != gBrowser.selectedBrowser) return false; diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js b/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js index 40be5b2a2dc..49c03909bf8 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js @@ -10,6 +10,7 @@ function runTests() { let path = PageThumbs.getThumbnailPath(URL); yield testIfExists(path, false, "Thumbnail file does not exist"); + yield addVisitsAndRepopulateNewTabLinks(URL, next); yield createThumbnail(URL); path = PageThumbs.getThumbnailPath(URL); diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js b/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js index 2e6fd0ff645..b87156d4cd8 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js @@ -36,6 +36,14 @@ function runTests() { {scheme: "https", cacheControl: "private", diskCacheSSL: false} ]; + let urls = positive.map((combi) => { + let url = combi.scheme + URL; + if (combi.cacheControl) + url += "?" + combi.cacheControl; + return url; + }); + yield addVisitsAndRepopulateNewTabLinks(urls, next); + yield checkCombinations(positive, true); yield checkCombinations(negative, false); } diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_storage.js b/toolkit/components/thumbnails/test/browser_thumbnails_storage.js index 4b64a0aafbf..d96dfcb0015 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_storage.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_storage.js @@ -19,6 +19,7 @@ XPCOMUtils.defineLazyGetter(this, "Sanitizer", function () { */ function runTests() { yield clearHistory(); + yield addVisitsAndRepopulateNewTabLinks(URL, next); yield createThumbnail(); // Make sure Storage.copy() updates an existing file. @@ -39,6 +40,7 @@ function runTests() { yield clearHistory(); } + yield addVisitsAndRepopulateNewTabLinks(URL, next); yield createThumbnail(); // Clear the last 10 minutes of browsing history. diff --git a/toolkit/components/thumbnails/test/head.js b/toolkit/components/thumbnails/test/head.js index 67b70d87ee2..edf6fad9237 100644 --- a/toolkit/components/thumbnails/test/head.js +++ b/toolkit/components/thumbnails/test/head.js @@ -4,10 +4,11 @@ let tmp = {}; Cu.import("resource://gre/modules/PageThumbs.jsm", tmp); Cu.import("resource://gre/modules/BackgroundPageThumbs.jsm", tmp); +Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp); Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp); Cu.import("resource://gre/modules/FileUtils.jsm", tmp); Cu.import("resource://gre/modules/osfile.jsm", tmp); -let {PageThumbs, BackgroundPageThumbs, PageThumbsStorage, SessionStore, FileUtils, OS} = tmp; +let {PageThumbs, BackgroundPageThumbs, NewTabUtils, PageThumbsStorage, SessionStore, FileUtils, OS} = tmp; Cu.import("resource://gre/modules/PlacesUtils.jsm"); @@ -199,11 +200,12 @@ function removeThumbnail(aURL) { * Asynchronously adds visits to a page, invoking a callback function when done. * * @param aPlaceInfo - * Can be an nsIURI, in such a case a single LINK visit will be added. - * Otherwise can be an object describing the visit to add, or an array - * of these objects: + * One of the following: a string spec, an nsIURI, an object describing + * the Place as described below, or an array of any such types. An + * object describing a Place must look like this: * { uri: nsIURI of the page, - * transition: one of the TRANSITION_* from nsINavHistoryService, + * [optional] transition: one of the TRANSITION_* from + * nsINavHistoryService, * [optional] title: title of the page, * [optional] visitDate: visit date in microseconds from the epoch * [optional] referrer: nsIURI of the referrer for this visit @@ -225,6 +227,9 @@ function addVisits(aPlaceInfo, aCallback) { // Create mozIVisitInfo for each entry. let now = Date.now(); for (let i = 0; i < places.length; i++) { + if (typeof(places[i] == "string")) { + places[i] = { uri: Services.io.newURI(places[i], "", null) }; + } if (!places[i].title) { places[i].title = "test visit for " + places[i].uri.spec; } @@ -251,6 +256,14 @@ function addVisits(aPlaceInfo, aCallback) { ); } +/** + * Calls addVisits, and then forces the newtab module to repopulate its links. + * See addVisits for parameter descriptions. + */ +function addVisitsAndRepopulateNewTabLinks(aPlaceInfo, aCallback) { + addVisits(aPlaceInfo, () => NewTabUtils.links.populateCache(aCallback, true)); +} + /** * Calls a given callback when the thumbnail for a given URL has been found * on disk. Keeps trying until the thumbnail has been created. diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index d0afef2f421..45a077db70d 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -621,7 +621,7 @@ let Links = { let pinnedLinks = Array.slice(PinnedLinks.links); // Filter blocked and pinned links. - let links = this._links.filter(function (link) { + let links = (this._links || []).filter(function (link) { return !BlockedLinks.isBlocked(link) && !PinnedLinks.isPinned(link); }); From da33efdbfac60de11bcc4cc6be225ebac45966f7 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 8 Jan 2014 20:16:48 -0800 Subject: [PATCH 2/5] Bug 945438 - Set event.cancelable for mousedown correctly on Metro [r=jimm] --- widget/windows/winrt/MetroInput.cpp | 39 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/widget/windows/winrt/MetroInput.cpp b/widget/windows/winrt/MetroInput.cpp index fb6fb27a27c..87bd5c601bc 100644 --- a/widget/windows/winrt/MetroInput.cpp +++ b/widget/windows/winrt/MetroInput.cpp @@ -408,40 +408,43 @@ MetroInput::OnPointerNonTouch(UI::Input::IPointerPoint* aPoint) { aPoint->get_Properties(props.GetAddressOf()); props->get_PointerUpdateKind(&pointerUpdateKind); - WidgetMouseEvent* event = - new WidgetMouseEvent(true, NS_MOUSE_MOVE, mWidget.Get(), - WidgetMouseEvent::eReal, - WidgetMouseEvent::eNormal); + uint32_t message = NS_MOUSE_MOVE; + int16_t button = 0; switch (pointerUpdateKind) { case UI::Input::PointerUpdateKind::PointerUpdateKind_LeftButtonPressed: - // We don't bother setting mouseEvent.button because it is already - // set to WidgetMouseEvent::buttonType::eLeftButton whose value is 0. - event->message = NS_MOUSE_BUTTON_DOWN; + button = WidgetMouseEvent::buttonType::eLeftButton; + message = NS_MOUSE_BUTTON_DOWN; break; case UI::Input::PointerUpdateKind::PointerUpdateKind_MiddleButtonPressed: - event->button = WidgetMouseEvent::buttonType::eMiddleButton; - event->message = NS_MOUSE_BUTTON_DOWN; + button = WidgetMouseEvent::buttonType::eMiddleButton; + message = NS_MOUSE_BUTTON_DOWN; break; case UI::Input::PointerUpdateKind::PointerUpdateKind_RightButtonPressed: - event->button = WidgetMouseEvent::buttonType::eRightButton; - event->message = NS_MOUSE_BUTTON_DOWN; + button = WidgetMouseEvent::buttonType::eRightButton; + message = NS_MOUSE_BUTTON_DOWN; break; case UI::Input::PointerUpdateKind::PointerUpdateKind_LeftButtonReleased: - // We don't bother setting mouseEvent.button because it is already - // set to WidgetMouseEvent::buttonType::eLeftButton whose value is 0. - event->message = NS_MOUSE_BUTTON_UP; + button = WidgetMouseEvent::buttonType::eLeftButton; + message = NS_MOUSE_BUTTON_UP; break; case UI::Input::PointerUpdateKind::PointerUpdateKind_MiddleButtonReleased: - event->button = WidgetMouseEvent::buttonType::eMiddleButton; - event->message = NS_MOUSE_BUTTON_UP; + button = WidgetMouseEvent::buttonType::eMiddleButton; + message = NS_MOUSE_BUTTON_UP; break; case UI::Input::PointerUpdateKind::PointerUpdateKind_RightButtonReleased: - event->button = WidgetMouseEvent::buttonType::eRightButton; - event->message = NS_MOUSE_BUTTON_UP; + button = WidgetMouseEvent::buttonType::eRightButton; + message = NS_MOUSE_BUTTON_UP; break; } + UpdateInputLevel(LEVEL_PRECISE); + + WidgetMouseEvent* event = + new WidgetMouseEvent(true, message, mWidget.Get(), + WidgetMouseEvent::eReal, + WidgetMouseEvent::eNormal); + event->button = button; InitGeckoMouseEventFromPointerPoint(event, aPoint); DispatchAsyncEventIgnoreStatus(event); } From e3aa02f5f657c178bcef476f376b2d6e12abe859 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 8 Jan 2014 20:16:48 -0800 Subject: [PATCH 3/5] Bug 957490 - Fix initialization of MouseEvent.buttons on Metro [r=jimm] --- .../tests/mochitest/browser_mouse_events.js | 51 +++++++++++++++++++ browser/metro/base/tests/mochitest/metro.ini | 5 +- widget/windows/KeyboardLayout.cpp | 5 ++ widget/windows/winrt/MetroInput.cpp | 32 ++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 browser/metro/base/tests/mochitest/browser_mouse_events.js diff --git a/browser/metro/base/tests/mochitest/browser_mouse_events.js b/browser/metro/base/tests/mochitest/browser_mouse_events.js new file mode 100644 index 00000000000..8095ca08d6c --- /dev/null +++ b/browser/metro/base/tests/mochitest/browser_mouse_events.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// from MouseEvents.h +const leftButtonFlag = 1; +const rightButtonFlag = 2; + +gTests.push({ + desc: "Test native mouse events", + run: function () { + let tab = yield addTab("about:mozilla"); + + // Mousemove. + let waitForMove = waitForEvent(document, "mousemove"); + synthesizeNativeMouseMove(tab.browser, 1, 1); + synthesizeNativeMouseMove(tab.browser, 100, 100); + let mousemove = yield waitForMove; + is(mousemove.cancelable, false, "mousemove is not cancelable"); + is(mousemove.buttons, 0, "no buttons are down"); + + // Left button down. + let waitForDown1 = waitForEvent(document, "mousedown"); + synthesizeNativeMouseLDown(tab.browser, 100, 100); + let mousedown1 = yield waitForDown1; + is(mousedown1.cancelable, true, "mousedown is cancelable"); + is(mousedown1.buttons, leftButtonFlag, "left button is down"); + + // Right button down. + let waitForDown2 = waitForEvent(document, "mousedown"); + synthesizeNativeMouseRDown(tab.browser, 100, 100); + let mousedown2 = yield waitForDown2; + is(mousedown2.buttons, leftButtonFlag | rightButtonFlag, "both buttons are down"); + + // Left button up. + let waitForUp1 = waitForEvent(document, "mouseup"); + synthesizeNativeMouseLUp(tab.browser, 100, 100); + let mouseup1 = yield waitForUp1; + is(mouseup1.buttons, rightButtonFlag, "right button is down"); + + // Right button up. + let waitForUp2 = waitForEvent(document, "mouseup"); + synthesizeNativeMouseRUp(tab.browser, 100, 100); + let mouseup2 = yield waitForUp2; + is(mouseup2.buttons, 0, "no buttons are down"); + + Browser.closeTab(tab, { forceClose: true }); + } +}); + +let test = runTests; diff --git a/browser/metro/base/tests/mochitest/metro.ini b/browser/metro/base/tests/mochitest/metro.ini index fdf0b716bcb..f8d1ce69865 100644 --- a/browser/metro/base/tests/mochitest/metro.ini +++ b/browser/metro/base/tests/mochitest/metro.ini @@ -32,6 +32,7 @@ support-files = res/blankpage2.html res/blankpage3.html +[browser_apzc_basic.js] [browser_bookmarks.js] [browser_canonizeURL.js] [browser_circular_progress_indicator.js] @@ -45,6 +46,8 @@ support-files = [browser_history.js] [browser_inputsource.js] [browser_link_click.js] +[browser_menu_hoverstate.js] +[browser_mouse_events.js] [browser_onscreen_keyboard.js] [browser_prefs_ui.js] [browser_prompt.js] @@ -58,8 +61,6 @@ support-files = [browser_urlbar.js] [browser_urlbar_highlightURLs.js] [browser_urlbar_trimURLs.js] -[browser_apzc_basic.js] -[browser_menu_hoverstate.js] # These tests have known failures in debug builds [browser_selection_basic.js] diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index 97ed8690e08..eb40b20312e 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -200,6 +200,11 @@ ModifierKeyState::InitMouseEvent(WidgetInputEvent& aMouseEvent) const aMouseEvent.eventStructType == NS_SIMPLE_GESTURE_EVENT, "called with non-mouse event"); + if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { + // Buttons for immersive mode are handled in MetroInput. + return; + } + WidgetMouseEventBase& mouseEvent = *aMouseEvent.AsMouseEventBase(); mouseEvent.buttons = 0; if (::GetKeyState(VK_LBUTTON) < 0) { diff --git a/widget/windows/winrt/MetroInput.cpp b/widget/windows/winrt/MetroInput.cpp index 87bd5c601bc..9cbe3bd9513 100644 --- a/widget/windows/winrt/MetroInput.cpp +++ b/widget/windows/winrt/MetroInput.cpp @@ -160,6 +160,37 @@ namespace { } } + int16_t + ButtonsForPointerPoint(UI::Input::IPointerPoint* aPoint) { + WRL::ComPtr props; + aPoint->get_Properties(props.GetAddressOf()); + + int16_t buttons = 0; + boolean buttonPressed; + + props->get_IsLeftButtonPressed(&buttonPressed); + if (buttonPressed) { + buttons |= WidgetMouseEvent::eLeftButtonFlag; + } + props->get_IsMiddleButtonPressed(&buttonPressed); + if (buttonPressed) { + buttons |= WidgetMouseEvent::eMiddleButtonFlag; + } + props->get_IsRightButtonPressed(&buttonPressed); + if (buttonPressed) { + buttons |= WidgetMouseEvent::eRightButtonFlag; + } + props->get_IsXButton1Pressed(&buttonPressed); + if (buttonPressed) { + buttons |= WidgetMouseEvent::e4thButtonFlag; + } + props->get_IsXButton2Pressed(&buttonPressed); + if (buttonPressed) { + buttons |= WidgetMouseEvent::e5thButtonFlag; + } + return buttons; + } + /** * This function is for use with mTouches.Enumerate. It will * append each element it encounters to the {@link nsTArray} @@ -749,6 +780,7 @@ MetroInput::InitGeckoMouseEventFromPointerPoint( aEvent->clickCount = 2; } aEvent->pressure = pressure; + aEvent->buttons = ButtonsForPointerPoint(aPointerPoint); MozInputSourceFromDeviceType(deviceType, aEvent->inputSource); } From ced5ec8db96e665df3769e2e38ff72fcf3b782f4 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 8 Jan 2014 20:16:48 -0800 Subject: [PATCH 4/5] Bug 952297 - Don't force scroll arrows to be visible in tab strip [r=sfoster] --- .../tests/mochitest/browser_tabs_container.js | 21 +++++++++++-------- browser/metro/theme/browser.css | 12 ++++------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/browser/metro/base/tests/mochitest/browser_tabs_container.js b/browser/metro/base/tests/mochitest/browser_tabs_container.js index ea9038efb64..52377268a9a 100644 --- a/browser/metro/base/tests/mochitest/browser_tabs_container.js +++ b/browser/metro/base/tests/mochitest/browser_tabs_container.js @@ -50,7 +50,7 @@ gTests.push({ notifyPrecise(); yield precisePromise; - todo(!isElementVisible(tabStrip._scrollButtonUp), "Bug 952297 - left scrollbutton is hidden in precise mode"); + ok(!isElementVisible(tabStrip._scrollButtonUp), "Bug 952297 - left scrollbutton is hidden in precise mode"); ok(!isElementVisible(tabStrip._scrollButtonDown), "right scrollbutton is hidden in precise mode"); }, tearDown: tearDown @@ -98,17 +98,20 @@ gTests.push({ yield addTab("about:mozilla"); } - let tabs = Elements.tabList.strip.querySelectorAll("documenttab"); - // select the first tab - Elements.tabs.selectedTab = tabs[0]; - ok(isElementVisible(Elements.tabList.strip._scrollButtonDown), "right scrollbutton should be visible when tabList has overflow"); - todo(!isElementVisible(Elements.tabList.strip._scrollButtonUp), "Bug 952297 - left scrollbutton should not visible when 1st tab is selected and tablist has overflow"); + ok(isElementVisible(Elements.tabList.strip._scrollButtonUp), "left scrollbutton should be visible in precise mode"); + ok(isElementVisible(Elements.tabList.strip._scrollButtonDown), "right scrollbutton should be visible in precise mode"); + // select the first tab + Browser.selectedTab = Browser.tabs[0]; + yield waitForMs(1000); // XXX maximum duration of arrowscrollbox _scrollAnim + ok(Elements.tabList.strip._scrollButtonUp.disabled, "left scrollbutton should be disabled when 1st tab is selected and tablist has overflow"); + ok(!Elements.tabList.strip._scrollButtonDown.disabled, "right scrollbutton should be enabled when 1st tab is selected and tablist has overflow"); // select the last tab - Elements.tabs.selectedTab = tabs[tabs.length-1]; - ok(isElementVisible(Elements.tabList.strip._scrollButtonUp), "left scrollbutton should be visible when tablist has overflow and last tab is selected"); - todo(!isElementVisible(Elements.tabList.strip._scrollButtonDown), "Bug 952297 - right scrollbutton should not visible when last tab is selected and tablist has overflow"); + Browser.selectedTab = Browser.tabs[Browser.tabs.length - 1]; + yield waitForMs(1000); // XXX maximum duration of arrowscrollbox _scrollAnim + ok(!Elements.tabList.strip._scrollButtonUp.disabled, "left scrollbutton should be enabled when 1st tab is selected and tablist has overflow"); + ok(Elements.tabList.strip._scrollButtonDown.disabled, "right scrollbutton should be disabled when last tab is selected and tablist has overflow"); } }); diff --git a/browser/metro/theme/browser.css b/browser/metro/theme/browser.css index 78aed659ed5..b8a5dcb6a5f 100644 --- a/browser/metro/theme/browser.css +++ b/browser/metro/theme/browser.css @@ -46,18 +46,14 @@ overflow: auto; } -#tabs[input="precise"] > .tabs-scrollbox > .scrollbutton-up { - visibility: visible !important; -} -#tabs[input="imprecise"] > .tabs-scrollbox > .scrollbutton-up { +.tabs-scrollbox > .scrollbutton-up[collapsed], +.tabs-scrollbox > .scrollbutton-down[collapsed], +#tabs[input="imprecise"] > .tabs-scrollbox > .scrollbutton-up, +#tabs[input="imprecise"] > .tabs-scrollbox > .scrollbutton-down { visibility: hidden !important; pointer-events: none; } -#tabs[input="imprecise"] > .tabs-scrollbox > .scrollbutton-down { - visibility: collapse !important; -} - #tabs > .tabs-scrollbox > .scrollbutton-up { list-style-image: url("images/tab-arrows.png") !important; -moz-image-region: rect(15px 58px 63px 14px) !important; From 834297bc125bf739af86901292ef3e4972f8014b Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Wed, 8 Jan 2014 22:02:28 -0800 Subject: [PATCH 5/5] Backed out changeset f552ce04bc36 (bug 809056) for m-bc orange --- browser/base/content/browser-thumbnails.js | 7 ------ .../test/browser_thumbnails_bug818225.js | 1 - .../test/browser_thumbnails_privacy.js | 8 ------- .../test/browser_thumbnails_storage.js | 2 -- toolkit/components/thumbnails/test/head.js | 23 ++++--------------- toolkit/modules/NewTabUtils.jsm | 2 +- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/browser/base/content/browser-thumbnails.js b/browser/base/content/browser-thumbnails.js index 754b7cf587c..e255dcc03ed 100644 --- a/browser/base/content/browser-thumbnails.js +++ b/browser/base/content/browser-thumbnails.js @@ -4,8 +4,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #endif -Cu.import("resource://gre/modules/NewTabUtils.jsm"); - /** * Keeps thumbnails of open web pages up-to-date. */ @@ -122,11 +120,6 @@ let gBrowserThumbnails = { }, _shouldCapture: function Thumbnails_shouldCapture(aBrowser) { - // Capture only if it's a top site in about:newtab. - if (!NewTabUtils.links.getLinks().some( - (link) => link.url == aBrowser.currentURI.spec)) - return false; - // Capture only if it's the currently selected tab. if (aBrowser != gBrowser.selectedBrowser) return false; diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js b/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js index 49c03909bf8..40be5b2a2dc 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bug818225.js @@ -10,7 +10,6 @@ function runTests() { let path = PageThumbs.getThumbnailPath(URL); yield testIfExists(path, false, "Thumbnail file does not exist"); - yield addVisitsAndRepopulateNewTabLinks(URL, next); yield createThumbnail(URL); path = PageThumbs.getThumbnailPath(URL); diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js b/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js index b87156d4cd8..2e6fd0ff645 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_privacy.js @@ -36,14 +36,6 @@ function runTests() { {scheme: "https", cacheControl: "private", diskCacheSSL: false} ]; - let urls = positive.map((combi) => { - let url = combi.scheme + URL; - if (combi.cacheControl) - url += "?" + combi.cacheControl; - return url; - }); - yield addVisitsAndRepopulateNewTabLinks(urls, next); - yield checkCombinations(positive, true); yield checkCombinations(negative, false); } diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_storage.js b/toolkit/components/thumbnails/test/browser_thumbnails_storage.js index d96dfcb0015..4b64a0aafbf 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_storage.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_storage.js @@ -19,7 +19,6 @@ XPCOMUtils.defineLazyGetter(this, "Sanitizer", function () { */ function runTests() { yield clearHistory(); - yield addVisitsAndRepopulateNewTabLinks(URL, next); yield createThumbnail(); // Make sure Storage.copy() updates an existing file. @@ -40,7 +39,6 @@ function runTests() { yield clearHistory(); } - yield addVisitsAndRepopulateNewTabLinks(URL, next); yield createThumbnail(); // Clear the last 10 minutes of browsing history. diff --git a/toolkit/components/thumbnails/test/head.js b/toolkit/components/thumbnails/test/head.js index edf6fad9237..67b70d87ee2 100644 --- a/toolkit/components/thumbnails/test/head.js +++ b/toolkit/components/thumbnails/test/head.js @@ -4,11 +4,10 @@ let tmp = {}; Cu.import("resource://gre/modules/PageThumbs.jsm", tmp); Cu.import("resource://gre/modules/BackgroundPageThumbs.jsm", tmp); -Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp); Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp); Cu.import("resource://gre/modules/FileUtils.jsm", tmp); Cu.import("resource://gre/modules/osfile.jsm", tmp); -let {PageThumbs, BackgroundPageThumbs, NewTabUtils, PageThumbsStorage, SessionStore, FileUtils, OS} = tmp; +let {PageThumbs, BackgroundPageThumbs, PageThumbsStorage, SessionStore, FileUtils, OS} = tmp; Cu.import("resource://gre/modules/PlacesUtils.jsm"); @@ -200,12 +199,11 @@ function removeThumbnail(aURL) { * Asynchronously adds visits to a page, invoking a callback function when done. * * @param aPlaceInfo - * One of the following: a string spec, an nsIURI, an object describing - * the Place as described below, or an array of any such types. An - * object describing a Place must look like this: + * Can be an nsIURI, in such a case a single LINK visit will be added. + * Otherwise can be an object describing the visit to add, or an array + * of these objects: * { uri: nsIURI of the page, - * [optional] transition: one of the TRANSITION_* from - * nsINavHistoryService, + * transition: one of the TRANSITION_* from nsINavHistoryService, * [optional] title: title of the page, * [optional] visitDate: visit date in microseconds from the epoch * [optional] referrer: nsIURI of the referrer for this visit @@ -227,9 +225,6 @@ function addVisits(aPlaceInfo, aCallback) { // Create mozIVisitInfo for each entry. let now = Date.now(); for (let i = 0; i < places.length; i++) { - if (typeof(places[i] == "string")) { - places[i] = { uri: Services.io.newURI(places[i], "", null) }; - } if (!places[i].title) { places[i].title = "test visit for " + places[i].uri.spec; } @@ -256,14 +251,6 @@ function addVisits(aPlaceInfo, aCallback) { ); } -/** - * Calls addVisits, and then forces the newtab module to repopulate its links. - * See addVisits for parameter descriptions. - */ -function addVisitsAndRepopulateNewTabLinks(aPlaceInfo, aCallback) { - addVisits(aPlaceInfo, () => NewTabUtils.links.populateCache(aCallback, true)); -} - /** * Calls a given callback when the thumbnail for a given URL has been found * on disk. Keeps trying until the thumbnail has been created. diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index 45a077db70d..d0afef2f421 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -621,7 +621,7 @@ let Links = { let pinnedLinks = Array.slice(PinnedLinks.links); // Filter blocked and pinned links. - let links = (this._links || []).filter(function (link) { + let links = this._links.filter(function (link) { return !BlockedLinks.isBlocked(link) && !PinnedLinks.isPinned(link); });