diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/performance/legacy/compatibility.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/performance/legacy/compatibility.js')
-rw-r--r-- | devtools/client/performance/legacy/compatibility.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/devtools/client/performance/legacy/compatibility.js b/devtools/client/performance/legacy/compatibility.js new file mode 100644 index 000000000..0c67800d0 --- /dev/null +++ b/devtools/client/performance/legacy/compatibility.js @@ -0,0 +1,66 @@ +/* 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"; + +const EventEmitter = require("devtools/shared/event-emitter"); + +/** + * A dummy front decorated with the provided methods. + * + * @param array blueprint + * A list of [funcName, retVal] describing the class. + */ +function MockFront(blueprint) { + EventEmitter.decorate(this); + + for (let [funcName, retVal] of blueprint) { + this[funcName] = (x => typeof x === "function" ? x() : x).bind(this, retVal); + } +} + +function MockTimelineFront() { + MockFront.call(this, [ + ["destroy"], + ["start", 0], + ["stop", 0], + ]); +} + +/** + * Takes a TabTarget, and checks existence of a TimelineActor on + * the server, or if TEST_MOCK_TIMELINE_ACTOR is to be used. + * + * @param {TabTarget} target + * @return {Boolean} + */ +function timelineActorSupported(target) { + // This `target` property is used only in tests to test + // instances where the timeline actor is not available. + if (target.TEST_MOCK_TIMELINE_ACTOR) { + return false; + } + + return target.hasActor("timeline"); +} + +/** + * Returns a function to be used as a method on an "Front" in ./actors. + * Calls the underlying actor's method. + */ +function callFrontMethod(method) { + return function () { + // If there's no target or client on this actor facade, + // abort silently -- this occurs in tests when polling occurs + // after the test ends, when tests do not wait for toolbox destruction + // (which will destroy the actor facade, turning off the polling). + if (!this._target || !this._target.client) { + return undefined; + } + return this._front[method].apply(this._front, arguments); + }; +} + +exports.MockTimelineFront = MockTimelineFront; +exports.timelineActorSupported = timelineActorSupported; +exports.callFrontMethod = callFrontMethod; |