Bug 1384977 - Remove unused PreviewProvider.jsm and refs, r=ursula?
MozReview-Commit-ID: Ee4uIdPJ0Cy
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -79,19 +79,16 @@ var whitelist = [
// Add-on API introduced in bug 1118285
{file: "resource://app/modules/NewTabURL.jsm"},
// browser/components/newtab bug 1355166
{file: "resource://app/modules/NewTabSearchProvider.jsm"},
{file: "resource://app/modules/NewTabWebChannel.jsm"},
- // Activity Stream currently needs this file in all channels except Nightly
- {file: "resource://app/modules/PreviewProvider.jsm", skipNightly: true},
-
// layout/mathml/nsMathMLChar.cpp
{file: "resource://gre/res/fonts/mathfontSTIXGeneral.properties"},
{file: "resource://gre/res/fonts/mathfontUnicode.properties"},
// toolkit/components/places/ColorAnalyzer_worker.js
{file: "resource://gre/modules/ClusterLib.js"},
{file: "resource://gre/modules/ColorConversion.js"},
deleted file mode 100644
--- a/browser/components/newtab/PreviewProvider.jsm
+++ /dev/null
@@ -1,45 +0,0 @@
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["PreviewProvider"];
-
-const {utils: Cu} = Components;
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/PageThumbs.jsm");
-Cu.import("resource://gre/modules/FileUtils.jsm");
-const {OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
-
-XPCOMUtils.defineLazyModuleGetter(this, "BackgroundPageThumbs",
- "resource://gre/modules/BackgroundPageThumbs.jsm");
-XPCOMUtils.defineLazyServiceGetter(this, "MIMEService",
- "@mozilla.org/mime;1", "nsIMIMEService");
-
-let PreviewProvider = {
- /**
- * Returns a thumbnail as a data URI for a url, creating it if necessary
- *
- * @param {String} url
- * a url to obtain a thumbnail for
- * @return {Promise} A Promise that resolves with a base64 encoded thumbnail
- */
- getThumbnail: async function PreviewProvider_getThumbnail(url) {
- try {
- await BackgroundPageThumbs.captureIfMissing(url);
- let imgPath = PageThumbsStorage.getFilePathForURL(url);
-
- // OS.File object used to easily read off-thread
- let file = await OS.File.open(imgPath, {read: true, existing: true});
-
- // nsIFile object needed for MIMEService
- let nsFile = FileUtils.File(imgPath);
-
- let contentType = MIMEService.getTypeFromFile(nsFile);
- let bytes = await file.read();
- let encodedData = btoa(String.fromCharCode.apply(null, bytes));
- file.close();
- return `data:${contentType};base64,${encodedData}`;
- } catch (err) {
- Cu.reportError(`PreviewProvider_getThumbnail error: ${err}`);
- throw err;
- }
- }
-};
--- a/browser/components/newtab/moz.build
+++ b/browser/components/newtab/moz.build
@@ -13,18 +13,17 @@ XPCSHELL_TESTS_MANIFESTS += [
'tests/xpcshell/xpcshell.ini',
]
EXTRA_JS_MODULES += [
'NewTabPrefsProvider.jsm',
'NewTabRemoteResources.jsm',
'NewTabSearchProvider.jsm',
'NewTabURL.jsm',
- 'NewTabWebChannel.jsm',
- 'PreviewProvider.jsm'
+ 'NewTabWebChannel.jsm'
]
XPIDL_SOURCES += [
'nsIAboutNewTabService.idl',
]
XPIDL_MODULE = 'browser-newtab'
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/blue_page.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-
-<html>
-<head>
- <meta charset="utf-8">
-</head>
-<body style="background-color: blue">
-</body>
-</html>
--- a/browser/components/newtab/tests/browser/browser.ini
+++ b/browser/components/newtab/tests/browser/browser.ini
@@ -1,9 +1,6 @@
[DEFAULT]
support-files =
- blue_page.html
dummy_page.html
-[browser_PreviewProvider.js]
-skip-if = os == 'linux' || os == 'win' # bug 1343150
[browser_remotenewtab_pageloads.js]
[browser_newtab_overrides.js]
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/browser_PreviewProvider.js
+++ /dev/null
@@ -1,87 +0,0 @@
-"use strict";
-
-let Cu = Components.utils;
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "PreviewProvider",
- "resource:///modules/PreviewProvider.jsm");
-
-var oldEnabledPref = Services.prefs.getBoolPref("browser.pagethumbnails.capturing_disabled");
-Services.prefs.setBoolPref("browser.pagethumbnails.capturing_disabled", false);
-
-registerCleanupFunction(function() {
- while (gBrowser.tabs.length > 1) {
- gBrowser.removeTab(gBrowser.tabs[1]);
- }
- Services.prefs.setBoolPref("browser.pagethumbnails.capturing_disabled", oldEnabledPref);
-});
-
-const TEST_URL = "https://example.com/browser/browser/components/newtab/tests/browser/blue_page.html";
-
-function pixelsForDataURI(dataURI, options) {
- return new Promise(resolve => {
- if (!options) {
- options = {};
- }
- let {width, height} = options;
- if (!width) {
- width = 100;
- }
- if (!height) {
- height = 100;
- }
-
- let htmlns = "http://www.w3.org/1999/xhtml";
- let img = document.createElementNS(htmlns, "img");
- img.setAttribute("src", dataURI);
-
- img.addEventListener("load", function() {
- let canvas = document.createElementNS(htmlns, "canvas");
- canvas.setAttribute("width", width);
- canvas.setAttribute("height", height);
- let ctx = canvas.getContext("2d");
- ctx.drawImage(img, 0, 0, width, height);
- let result = ctx.getImageData(0, 0, width, height).data;
- resolve(result);
- }, {once: true});
- });
-}
-
-function* chunk_four(listData) {
- let index = 0;
- while (index < listData.length) {
- yield listData.slice(index, index + 5);
- index += 4;
- }
-}
-
-add_task(async function open_page() {
- let dataURI = await PreviewProvider.getThumbnail(TEST_URL);
- let pixels = await pixelsForDataURI(dataURI, {width: 10, height: 10});
- let rgbCount = {r: 0, g: 0, b: 0, a: 0};
- for (let [r, g, b, a] of chunk_four(pixels)) {
- if (r === 255) {
- rgbCount.r += 1;
- }
- if (g === 255) {
- rgbCount.g += 1;
- }
- if (b === 255) {
- rgbCount.b += 1;
- }
- if (a === 255) {
- rgbCount.a += 1;
- }
- }
- Assert.equal(`${rgbCount.r},${rgbCount.g},${rgbCount.b},${rgbCount.a}`,
- "0,0,100,100", "there should be 100 blue-only pixels at full opacity");
-});
-
-add_task(async function invalid_url() {
- try {
- await PreviewProvider.getThumbnail("invalid:URL");
- } catch (err) {
- Assert.ok(true, "URL Failed");
- }
-});
--- a/browser/extensions/activity-stream/lib/TopSitesFeed.jsm
+++ b/browser/extensions/activity-stream/lib/TopSitesFeed.jsm
@@ -7,19 +7,16 @@ const {utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const {actionCreators: ac, actionTypes: at} = Cu.import("resource://activity-stream/common/Actions.jsm", {});
const {Prefs} = Cu.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm", {});
const {insertPinned} = Cu.import("resource://activity-stream/common/Reducers.jsm", {});
XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils",
"resource://gre/modules/NewTabUtils.jsm");
-// Keep a reference to PreviewProvider.jsm until it's good to remove. See #2849
-XPCOMUtils.defineLazyModuleGetter(this, "PreviewProvider",
- "resource://app/modules/PreviewProvider.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Screenshots",
"resource://activity-stream/lib/Screenshots.jsm");
const TOP_SITES_SHOWMORE_LENGTH = 12;
const UPDATE_TIME = 15 * 60 * 1000; // 15 minutes
const DEFAULT_TOP_SITES = [];
this.TopSitesFeed = class TopSitesFeed {