Files
roytam1 573e7dd316 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1220564 - Remove legacy generator comprehensions. (r=Waldo) (762c83b25f)
- Bug 1220564 - Update and remove obsolete jit-tests. (r=Waldo) (cd56eda223)
- Bug 1220564 - Update and remove obsolete JS reftests. (r=Waldo) (3a36a4f4e5)
- Bug 1139736 - Part 1: map settings "network.debugging.enabled" to preference. r=fabrice (594fc01429)
- Bug 1210740 - Expose tracking protection setting to Gaia, r=fabrice (38daca12a0)
- Bug 1163956 - Modify updatePath to fixed char array. r=gsvelto (56fec01263)
- Bug 1229620 - Replace #ifdefs in b2g/ code by AppConstants r=timdream (7cc5dce39d)
- Bug 1214515 - PersistentDataBlock b2g component implementation. r=gerard-majax (eadc3d53ca)
- Bug 1220564 - Update chrome code uses of genexprs and legacy comprehensions. (r=billm) (0dea4b39fd)
- Bug 1234738 - Emit ALIASEDVAR ops or block-scoped lexicals right below global level. (r=jorendorff) (7c8eb66a00)
- Bug 1221144 - Part 1: Make static scope objects a separate class hierarchy from the runtime ScopeObjects. r=shu. (1c74551384)
- Bug 1237564 - Fix minor bug with a lexical declaration shadowing a non-configurable global. r=shu (fcb3040151)
- Bug 1237501. Actually create a baseline IC for a JSNative accessor property get that's unshadowed on a DOM proxy. We apparently failed to ever do this. r=jandem (e2e4222197)
- Bug 1234663: SharedStubs: Use correct fallbackstubspace to keep stubs# , r=jandm (591fbcd885)
- Bug 1234414 - Consider the initial values at block entry to be within block note bounds. (r=jorendorff) (321a016320)
- Bug 1214059: Baseline: Enable switch to debug mode at function entry, r=jandem (b803a7206d)
- Bug 1233179 - Allow bytecode emitter to access module environment before module declarations are instantiated r=shu (e6d23fc2af)
- Bug 1220564 - Remove legacy array comprehensions. (r=Waldo) (73973ac52e)
- Bug 1228976 - Remove array comprehensions from Places .r=mak (10274eaaef)
- Bug 1239753 - FirefoxProfileMigrator is broken after generator expression removal. r=gijs (da1fbf8ca7)
- Bug 1229519: Fix toolkit/components/thumbnails to pass eslint checks. r=rhelmer (2a710ab167)
- Bug 1041537 - Prevent ContentSearch from leaking the browser if it's still processing a message while the test suite shuts down r=adw (b62ad37cdd)
- Bug 1204361 - New Tab Page doesn't honor my "x" clicks on Suggested Tiles; instead of removing the tile, it swaps in a very similar one. [r=emtwo] (3260d90a44)
- Bug 1119442 - Update hang ui, remove drop down options and replace with simpler 'just fix it' button interface. r=mconley (29046ca45c)
- Bug 1233470 - make browser/modules eslintable, r=Mossop (aeb556ba66)
- Bug 1236875 - Fix BytecodeEmitter::atBodyLevel() for modules r=efaust (2fca7e49f2)
- Bug 1221144 - Part 2: Rename static scope classes away from "ScopeObject". r=shu. (dc2f110ef2)
- Bug 1221144 - Part 3: Rename variables, arguments, and fields that point to static scopes away from names that indicate objects, like "scopeObj" and "blockObj". r=shu. (33d1504d55)
- Bug 1221144 - Part 4: Rename a few functions about scopes away from names that indicate objects, like js::CloneNestedScopeObject. r=shu. (9551101431)
- Bug 1221144 - Part 5: Delete class js::BlockObject. r=shu. (5b4746c5a5)
- Bug 1221144 - Part 6: Introduce StaticModuleScope. Pretty silly so far. Bindings are still stored in the script. r=shu. (b90c20e255)
- Bug 1221144 - Part 7: Introduce StaticFunctionScope, same story. r=shu. (eb39a2359b)
- Bug 1221144 - Part 8: Change C++ type of static scopes everywhere from JSObject* to StaticScope*. r=shu. (f1edf54510)
- Bug 1221144 - Part 9: A few more JSObject* -> StaticScope* changes. r=shu. (000d52709b)
- Bug 1221144 - Part 10: Delete an obsolete comment. r=shu. (f0655f736b)
- Bug 1221144 - Part 12: Remove StaticScopeIter<>::IsStaticScope. r=shu. (9653f2c544)
- Bug 1221144 - Part 13: Change DumpStaticScopeChain to include a function scope when available, on the theory that more information is better. r=shu. (7dd24064c8)
- Bug 1221144 - Part 14: Handlify scope arguments to methods around FunctionBox creation. r=shu. (902020bf08)
- Fix busted test checked in with bug 1221144. r=red. (9d8ff7f3be)
- Bug 1235590 - Allow redeclaring block-scoped functions and warn about deprecation for now. (r=jorendorff) (1e8a6ca2bb)
- Bug 1245321 - Merge the object and regexp lists in script data. r=jorendorff. (4f429f9d7b)
- Bug 1230633 - User is unable to enable full devtools/developer mode r=me (a9ee457fec)
- backout Bug 1221144 for perf regression (0c24810d37)
- Bug 1207490 - Part 11: Remove use of expression closure from browser/modules/DirectoryLinksProvider.jsm. r=Gijs (f7f844130a)
- Bug 1240245 - Disable data collection for new-tab page r=jaws (a7a40f394b)
- Bug 526620 - Intelligently invalidate other tabs' previews on resize, flushing their layout when necessary. r=jimm (30ce73281d)
- Bug 1122356 - Remove use of expression closures from WindowsPreviewPerTab.jsm. r=dao (bb3fde452e)
- Bug 1207490 - Part 15: Remove use of expression closure from browser/modules/WindowsPreviewPerTab.jsm. r=Gijs (3904885596)
- Bug 1233925 - Treat functions with rest more like functions with lazy arguments. r=nbp (7e6ec266e1)
- Bug 1243397 - Ensure enough ballast space in LiveRange::FallibleNew. r=h4writer (d36353ed01)
- Bug 1229636 - Remove new tab first time use message. r=gijs (57a1df93cf)
- Bug 1245154 - Ensure enough ballast space in LiveBundle::FallibleNew. r=h4writer (46863982c0)
- Bug 1245176 - Ensure enough ballast space in BacktrackingAllocator::reifyAllocations. r=h4writer (289d71a6cb)
- Bug 1231024 - Fix printing of live bundle information in regalloc spew, r=jonco. (fb4449119f)
- Bug 1244215 part 1 - Store frame header size in the frame descriptor. r=nbp (e666793f3c)
- Bug 1234425 - Skip accessor IC frames in GetPcScript. r=h4writer (5981b361ad)
- Bug 1244215 part 2 - Get rid of unwound frames and clean up a lot of code in this area. r=nbp (96de454424)
- Bug 1244215 part 3 - Remove lazy link frames, they're no longer necessary. r=nbp (32637085a0)
- Bug 1225041 - Implement ES6 Annex B.3.5. (r=jorendorff) (718e230725)
- Bug 1224310 - Suggested tiles requires two blocks to stop showing in newtab [r=marcosc] (53aed2c8a8)
- Bug 912337 - Update docs on Debugger.DebuggeeWouldRun. (r=jimb) (f4a88f0f93)
- Bug 1236316 - Suppress GC in ActivationEntryMonitor constructors; should fix a ton of dt oranges. r=fitzgen (122a436137)
- Bug 1238575 - Fix shell evalInWorker() to wait for thread if it exitsearly r=terrence (dd0ef6414a)
- Bug 1243706 - Release PerformanceStats/PerformanceWatcher;r=Felipe (1a36dce39e)
- Bug 912337 - Tests. (r=jimb) (463a89f8fc)
- Bug 912337 - Update existing tests. (r=jimb) (bf57c020a9)
- Bug 912337 - Make a pref to toggle whether DebuggeeWouldRun is a warning or an error. (r=jimb) (3fd12fe0c3)
- Bug 912337 - Make DebuggeeWouldRun report filename and lineno. (r=me) (56ace0f5e4)
- Bug 1232685 - Prevent forcing illegal return values in derived class constructors. (r=shu, a=kwierso) (f15c51b1fd)
- Bug 1243754 - IonMonkey: Use 'delete' to destroy the ion script instead of 'free', r=jandem (74df94e3a2)
2023-09-04 16:37:44 +08:00

417 lines
14 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
let Cc = Components.classes;
let Ci = Components.interfaces;
let Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/MigrationUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PropertyListUtils",
"resource://gre/modules/PropertyListUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
"resource://gre/modules/FormHistory.jsm");
function Bookmarks(aBookmarksFile) {
this._file = aBookmarksFile;
}
Bookmarks.prototype = {
type: MigrationUtils.resourceTypes.BOOKMARKS,
migrate: function B_migrate(aCallback) {
PropertyListUtils.read(this._file,
MigrationUtils.wrapMigrateFunction(function migrateBookmarks(aDict) {
if (!aDict)
throw new Error("Could not read Bookmarks.plist");
let children = aDict.get("Children");;
if (!children)
throw new Error("Invalid Bookmarks.plist format");
PlacesUtils.bookmarks.runInBatchMode({
runBatched: function() {
let collection = aDict.get("Title") == "com.apple.ReadingList" ?
this.READING_LIST_COLLECTION : this.ROOT_COLLECTION;
this._migrateCollection(children, collection);
}.bind(this)
}, null);
}.bind(this), aCallback));
},
// Bookmarks collections in Safari. Constants for migrateCollection.
ROOT_COLLECTION: 0,
MENU_COLLECTION: 1,
TOOLBAR_COLLECTION: 2,
READING_LIST_COLLECTION: 3,
/**
* Recursively migrate a Safari collection of bookmarks.
*
* @param aEntries
* the collection's children
* @param aCollection
* one of the values above.
*/
_migrateCollection: function B__migrateCollection(aEntries, aCollection) {
// A collection of bookmarks in Safari resembles places roots. In the
// property list files (Bookmarks.plist, ReadingList.plist) they are
// stored as regular bookmarks folders, and thus can only be distinguished
// from by their names and places in the hierarchy.
let entriesFiltered = [];
if (aCollection == this.ROOT_COLLECTION) {
for (let entry of aEntries) {
let type = entry.get("WebBookmarkType");
if (type == "WebBookmarkTypeList" && entry.has("Children")) {
let title = entry.get("Title");
let children = entry.get("Children");
if (title == "BookmarksBar")
this._migrateCollection(children, this.TOOLBAR_COLLECTION);
else if (title == "BookmarksMenu")
this._migrateCollection(children, this.MENU_COLLECTION);
else if (title == "com.apple.ReadingList")
this._migrateCollection(children, this.READING_LIST_COLLECTION);
else if (entry.get("ShouldOmitFromUI") !== true)
entriesFiltered.push(entry);
}
else if (type == "WebBookmarkTypeLeaf") {
entriesFiltered.push(entry);
}
}
}
else {
entriesFiltered = aEntries;
}
if (entriesFiltered.length == 0)
return;
let folder = -1;
switch (aCollection) {
case this.ROOT_COLLECTION: {
// In Safari, it is possible (though quite cumbersome) to move
// bookmarks to the bookmarks root, which is the parent folder of
// all bookmarks "collections". That is somewhat in parallel with
// both the places root and the unfiled-bookmarks root.
// Because the former is only an implementation detail in our UI,
// the unfiled root seems to be the best choice.
folder = PlacesUtils.unfiledBookmarksFolderId;
break;
}
case this.MENU_COLLECTION: {
folder = PlacesUtils.bookmarksMenuFolderId;
if (!MigrationUtils.isStartupMigration) {
folder = MigrationUtils.createImportedBookmarksFolder("Safari",
folder);
}
break;
}
case this.TOOLBAR_COLLECTION: {
folder = PlacesUtils.toolbarFolderId;
if (!MigrationUtils.isStartupMigration) {
folder = MigrationUtils.createImportedBookmarksFolder("Safari",
folder);
}
break;
}
case this.READING_LIST_COLLECTION: {
// Reading list items are imported as regular bookmarks.
// They are imported under their own folder, created either under the
// bookmarks menu (in the case of startup migration).
folder = PlacesUtils.bookmarks.createFolder(
PlacesUtils.bookmarksMenuFolderId,
MigrationUtils.getLocalizedString("importedSafariReadingList"),
PlacesUtils.bookmarks.DEFAULT_INDEX);
break;
}
default:
throw new Error("Unexpected value for aCollection!");
}
this._migrateEntries(entriesFiltered, folder);
},
// migrate the given array of safari bookmarks to the given places
// folder.
_migrateEntries: function B__migrateEntries(aEntries, aFolderId) {
for (let entry of aEntries) {
let type = entry.get("WebBookmarkType");
if (type == "WebBookmarkTypeList" && entry.has("Children")) {
let title = entry.get("Title");
let folderId = PlacesUtils.bookmarks.createFolder(
aFolderId, title, PlacesUtils.bookmarks.DEFAULT_INDEX);
// Empty folders may not have a children array.
if (entry.has("Children"))
this._migrateEntries(entry.get("Children"), folderId, false);
}
else if (type == "WebBookmarkTypeLeaf" && entry.has("URLString")) {
let title, uri;
if (entry.has("URIDictionary"))
title = entry.get("URIDictionary").get("title");
try {
uri = NetUtil.newURI(entry.get("URLString"));
}
catch(ex) {
Cu.reportError("Invalid uri set for Safari bookmark: " + entry.get("URLString"));
}
if (uri) {
PlacesUtils.bookmarks.insertBookmark(aFolderId, uri,
PlacesUtils.bookmarks.DEFAULT_INDEX, title);
}
}
}
}
};
function History(aHistoryFile) {
this._file = aHistoryFile;
}
History.prototype = {
type: MigrationUtils.resourceTypes.HISTORY,
// Helper method for converting the visit date property to a PRTime value.
// The visit date is stored as a string, so it's not read as a Date
// object by PropertyListUtils.
_parseCocoaDate: function H___parseCocoaDate(aCocoaDateStr) {
let asDouble = parseFloat(aCocoaDateStr);
if (!isNaN(asDouble)) {
// reference date of NSDate.
let date = new Date("1 January 2001, GMT");
date.setMilliseconds(asDouble * 1000);
return date * 1000;
}
return 0;
},
migrate: function H_migrate(aCallback) {
PropertyListUtils.read(this._file, function migrateHistory(aDict) {
try {
if (!aDict)
throw new Error("Could not read history property list");
if (!aDict.has("WebHistoryDates"))
throw new Error("Unexpected history-property list format");
// Safari's History file contains only top-level urls. It does not
// distinguish between typed urls and linked urls.
let transType = PlacesUtils.history.TRANSITION_LINK;
let places = [];
let entries = aDict.get("WebHistoryDates");
for (let entry of entries) {
if (entry.has("lastVisitedDate")) {
let visitDate = this._parseCocoaDate(entry.get("lastVisitedDate"));
places.push({ uri: NetUtil.newURI(entry.get("")),
title: entry.get("title"),
visits: [{ transitionType: transType,
visitDate: visitDate }] });
}
}
if (places.length > 0) {
PlacesUtils.asyncHistory.updatePlaces(places, {
_success: false,
handleResult: function() {
// Importing any entry is considered a successful import.
this._success = true;
},
handleError: function() {},
handleCompletion: function() {
aCallback(this._success);
}
});
}
else {
aCallback(false);
}
}
catch(ex) {
Cu.reportError(ex);
aCallback(false);
}
}.bind(this));
}
};
/**
* Safari's preferences property list is independently used for three purposes:
* (a) importation of preferences
* (b) importation of search strings
* (c) retrieving the home page.
*
* So, rather than reading it three times, it's cached and managed here.
*/
function MainPreferencesPropertyList(aPreferencesFile) {
this._file = aPreferencesFile;
this._callbacks = [];
}
MainPreferencesPropertyList.prototype = {
/**
* @see PropertyListUtils.read
*/
read: function MPPL_read(aCallback) {
if ("_dict" in this) {
aCallback(this._dict);
return;
}
let alreadyReading = this._callbacks.length > 0;
this._callbacks.push(aCallback);
if (!alreadyReading) {
PropertyListUtils.read(this._file, function readPrefs(aDict) {
this._dict = aDict;
for (let callback of this._callbacks) {
try {
callback(aDict);
}
catch(ex) {
Cu.reportError(ex);
}
}
this._callbacks.splice(0);
}.bind(this));
}
},
// Workaround for nsIBrowserProfileMigrator.sourceHomePageURL until
// it's replaced with an async method.
_readSync: function MPPL__readSync() {
if ("_dict" in this)
return this._dict;
let inputStream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
inputStream.init(this._file, -1, -1, 0);
let binaryStream = Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
binaryStream.setInputStream(inputStream);
let bytes = binaryStream.readByteArray(inputStream.available());
this._dict = PropertyListUtils._readFromArrayBufferSync(
Uint8Array(bytes).buffer);
return this._dict;
}
};
function SearchStrings(aMainPreferencesPropertyListInstance) {
this._mainPreferencesPropertyList = aMainPreferencesPropertyListInstance;
}
SearchStrings.prototype = {
type: MigrationUtils.resourceTypes.OTHERDATA,
migrate: function SS_migrate(aCallback) {
this._mainPreferencesPropertyList.read(MigrationUtils.wrapMigrateFunction(
function migrateSearchStrings(aDict) {
if (!aDict)
throw new Error("Could not get preferences dictionary");
if (aDict.has("RecentSearchStrings")) {
let recentSearchStrings = aDict.get("RecentSearchStrings");
if (recentSearchStrings && recentSearchStrings.length > 0) {
let changes = recentSearchStrings.map((searchString) => (
{op: "add",
fieldname: "searchbar-history",
value: searchString}));
FormHistory.update(changes);
}
}
}.bind(this), aCallback));
}
};
function SafariProfileMigrator() {
}
SafariProfileMigrator.prototype = Object.create(MigratorPrototype);
SafariProfileMigrator.prototype.getResources = function SM_getResources() {
let profileDir =
#ifdef XP_MACOSX
FileUtils.getDir("ULibDir", ["Safari"], false);
#else
FileUtils.getDir("AppData", ["Apple Computer", "Safari"], false);
#endif
if (!profileDir.exists())
return null;
let resources = [];
let pushProfileFileResource = function(aFileName, aConstructor) {
let file = profileDir.clone();
file.append(aFileName);
if (file.exists())
resources.push(new aConstructor(file));
};
pushProfileFileResource("History.plist", History);
pushProfileFileResource("Bookmarks.plist", Bookmarks);
// The Reading List feature was introduced at the same time in Windows and
// Mac versions of Safari. Not surprisingly, they are stored in the same
// format in both versions. Surpsingly, only on Windows there is a
// separate property list for it. This isn't #ifdefed out on mac, because
// Apple may fix this at some point.
pushProfileFileResource("ReadingList.plist", Bookmarks);
let prefsDir =
#ifdef XP_MACOSX
FileUtils.getDir("UsrPrfs", [], false);
#else
FileUtils.getDir("AppData", ["Apple Computer", "Preferences"], false);
#endif
let prefs = this.mainPreferencesPropertyList;
if (prefs) {
resources.push(new SearchStrings(prefs));
}
return resources;
};
Object.defineProperty(SafariProfileMigrator.prototype, "mainPreferencesPropertyList", {
get: function get_mainPreferencesPropertyList() {
if (this._mainPreferencesPropertyList === undefined) {
let file =
#ifdef XP_MACOSX
FileUtils.getDir("UsrPrfs", [], false);
#else
FileUtils.getDir("AppData", ["Apple Computer", "Preferences"], false);
#endif
if (file.exists()) {
file.append("com.apple.Safari.plist");
if (file.exists()) {
return this._mainPreferencesPropertyList =
new MainPreferencesPropertyList(file);
}
}
return this._mainPreferencesPropertyList = null;
}
return this._mainPreferencesPropertyList;
}
});
Object.defineProperty(SafariProfileMigrator.prototype, "sourceHomePageURL", {
get: function get_sourceHomePageURL() {
if (this.mainPreferencesPropertyList) {
let dict = this.mainPreferencesPropertyList._readSync();
if (dict.has("HomePage"))
return dict.get("HomePage");
}
return "";
}
});
SafariProfileMigrator.prototype.classDescription = "Safari Profile Migrator";
SafariProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=safari";
SafariProfileMigrator.prototype.classID = Components.ID("{4b609ecf-60b2-4655-9df4-dc149e474da1}");
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SafariProfileMigrator]);