зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1405008 - Make WebIDE warn when connecting to old runtimes. r=jdescottes
MozReview-Commit-ID: KQc2b1ohksA --HG-- extra : rebase_source : 0c0159ae17c7c224600aca2fe3611296dfea2bae
This commit is contained in:
Родитель
42905c6aec
Коммит
e2eb1ab79d
|
@ -48,6 +48,9 @@ error_folderCreationFailed=Unable to create project folder in the selected direc
|
|||
# Variable: runtime app build ID (looks like this %Y%M%D format) and firefox build ID (same format)
|
||||
error_runtimeVersionTooRecent=The connected runtime has a more recent build date (%1$S) than your desktop Firefox (%2$S) does. This is an unsupported setup and may cause DevTools to fail. Please update Firefox.
|
||||
|
||||
# Variable: runtime app version (looks like this 52.a3) and firefox version (same format)
|
||||
error_runtimeVersionTooOld=The connected runtime has an old version (%1$S). The minimum supported version is (%2$S). This is an unsupported setup and may cause DevTools to fail. Please update the connected runtime.
|
||||
|
||||
addons_stable=stable
|
||||
addons_unstable=unstable
|
||||
addons_install_button=install
|
||||
|
|
|
@ -31,8 +31,6 @@ const HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Troubleshootin
|
|||
const MAX_ZOOM = 1.4;
|
||||
const MIN_ZOOM = 0.6;
|
||||
|
||||
const MS_PER_DAY = 86400000;
|
||||
|
||||
[["AppManager", AppManager],
|
||||
["AppProjects", AppProjects],
|
||||
["Connection", Connection]].forEach(([key, value]) => {
|
||||
|
@ -752,27 +750,17 @@ var UI = {
|
|||
deck.selectedPanel = null;
|
||||
},
|
||||
|
||||
buildIDToDate(buildID) {
|
||||
let fields = buildID.match(/(\d{4})(\d{2})(\d{2})/);
|
||||
// Date expects 0 - 11 for months
|
||||
return new Date(fields[1], Number.parseInt(fields[2]) - 1, fields[3]);
|
||||
},
|
||||
|
||||
checkRuntimeVersion: Task.async(function* () {
|
||||
if (AppManager.connected && AppManager.deviceFront) {
|
||||
let desc = yield AppManager.deviceFront.getDescription();
|
||||
// Compare device and firefox build IDs
|
||||
// and only compare by day (strip hours/minutes) to prevent
|
||||
// warning against builds of the same day.
|
||||
let deviceID = desc.appbuildid.substr(0, 8);
|
||||
let localID = Services.appinfo.appBuildID.substr(0, 8);
|
||||
let deviceDate = this.buildIDToDate(deviceID);
|
||||
let localDate = this.buildIDToDate(localID);
|
||||
// Allow device to be newer by up to a week. This accommodates those with
|
||||
// local device builds, since their devices will almost always be newer
|
||||
// than the client.
|
||||
if (deviceDate - localDate > 7 * MS_PER_DAY) {
|
||||
this.reportError("error_runtimeVersionTooRecent", deviceID, localID);
|
||||
if (AppManager.connected) {
|
||||
let { client } = AppManager.connection;
|
||||
let report = yield client.checkRuntimeVersion(AppManager.listTabsForm);
|
||||
if (report.incompatible == "too-recent") {
|
||||
this.reportError("error_runtimeVersionTooRecent", report.runtimeID,
|
||||
report.localID);
|
||||
}
|
||||
if (report.incompatible == "too-old") {
|
||||
this.reportError("error_runtimeVersionTooOld", report.runtimeVersion,
|
||||
report.minVersion);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
|
|
@ -539,6 +539,10 @@ var AppManager = exports.AppManager = {
|
|||
this._listTabsResponse.consoleActor);
|
||||
},
|
||||
|
||||
get listTabsForm() {
|
||||
return this._listTabsResponse;
|
||||
},
|
||||
|
||||
get deviceFront() {
|
||||
if (!this._listTabsResponse) {
|
||||
return null;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
|
||||
|
||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
|
@ -19,6 +20,8 @@ const {
|
|||
loader.lazyRequireGetter(this, "Authentication", "devtools/shared/security/auth");
|
||||
loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socket", true);
|
||||
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
||||
loader.lazyRequireGetter(this, "getDeviceFront", "devtools/shared/fronts/device", true);
|
||||
|
||||
loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true);
|
||||
loader.lazyRequireGetter(this, "AddonClient", "devtools/shared/client/addon-client");
|
||||
loader.lazyRequireGetter(this, "RootClient", "devtools/shared/client/root-client");
|
||||
|
@ -29,6 +32,12 @@ loader.lazyRequireGetter(this, "WorkerClient", "devtools/shared/client/worker-cl
|
|||
|
||||
const noop = () => {};
|
||||
|
||||
// Define the minimum officially supported version of Firefox when connecting to a remote
|
||||
// runtime. (Use ".0a1" to support the very first nightly version)
|
||||
// This is usually the current ESR version.
|
||||
const MIN_SUPPORTED_PLATFORM_VERSION = "52.0a1";
|
||||
const MS_PER_DAY = 86400000;
|
||||
|
||||
/**
|
||||
* Creates a client for the remote debugging protocol server. This client
|
||||
* provides the means to communicate with the server and exchange the messages
|
||||
|
@ -183,6 +192,66 @@ DebuggerClient.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Tells if the remote device is using a supported version of Firefox.
|
||||
*
|
||||
* @return Object with the following attributes:
|
||||
* * String incompatible
|
||||
* null if the runtime is compatible,
|
||||
* "too-recent" if the runtime uses a too recent version,
|
||||
* "too-old" if the runtime uses a too old version.
|
||||
* * String minVersion
|
||||
* The minimum supported version.
|
||||
* * String runtimeVersion
|
||||
* The remote runtime version.
|
||||
* * String localID
|
||||
* Build ID of local runtime. A date with like this: YYYYMMDD.
|
||||
* * String deviceID
|
||||
* Build ID of remote runtime. A date with like this: YYYYMMDD.
|
||||
*/
|
||||
async checkRuntimeVersion(listTabsForm) {
|
||||
let incompatible = null;
|
||||
|
||||
// Instead of requiring to pass `listTabsForm` here,
|
||||
// we can call getRoot() instead, but only once Firefox ESR59 is released
|
||||
let deviceFront = await getDeviceFront(this, listTabsForm);
|
||||
let desc = await deviceFront.getDescription();
|
||||
|
||||
// 1) Check for Firefox too recent on device.
|
||||
// Compare device and firefox build IDs
|
||||
// and only compare by day (strip hours/minutes) to prevent
|
||||
// warning against builds of the same day.
|
||||
let runtimeID = desc.appbuildid.substr(0, 8);
|
||||
let localID = Services.appinfo.appBuildID.substr(0, 8);
|
||||
function buildIDToDate(buildID) {
|
||||
let fields = buildID.match(/(\d{4})(\d{2})(\d{2})/);
|
||||
// Date expects 0 - 11 for months
|
||||
return new Date(fields[1], Number.parseInt(fields[2], 10) - 1, fields[3]);
|
||||
}
|
||||
let runtimeDate = buildIDToDate(runtimeID);
|
||||
let localDate = buildIDToDate(localID);
|
||||
// Allow device to be newer by up to a week. This accommodates those with
|
||||
// local device builds, since their devices will almost always be newer
|
||||
// than the client.
|
||||
if (runtimeDate - localDate > 7 * MS_PER_DAY) {
|
||||
incompatible = "too-recent";
|
||||
}
|
||||
|
||||
// 2) Check for too old Firefox on device
|
||||
let platformversion = desc.platformversion;
|
||||
if (Services.vc.compare(platformversion, MIN_SUPPORTED_PLATFORM_VERSION) < 0) {
|
||||
incompatible = "too-old";
|
||||
}
|
||||
|
||||
return {
|
||||
incompatible,
|
||||
minVersion: MIN_SUPPORTED_PLATFORM_VERSION,
|
||||
runtimeVersion: platformversion,
|
||||
localID,
|
||||
runtimeID,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Shut down communication with the debugging server.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче