mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-11-03 04:57:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
103
devtools/client/responsive.html/utils/e10s.js
Normal file
103
devtools/client/responsive.html/utils/e10s.js
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/* 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 { defer } = require("promise");
|
||||
|
||||
// The prefix used for RDM messages in content.
|
||||
// see: devtools/client/responsivedesign/responsivedesign-child.js
|
||||
const MESSAGE_PREFIX = "ResponsiveMode:";
|
||||
const REQUEST_DONE_SUFFIX = ":Done";
|
||||
|
||||
/**
|
||||
* Registers a message `listener` that is called every time messages of
|
||||
* specified `message` is emitted on the given message manager.
|
||||
* @param {nsIMessageListenerManager} mm
|
||||
* The Message Manager
|
||||
* @param {String} message
|
||||
* The message. It will be prefixed with the constant `MESSAGE_PREFIX`
|
||||
* @param {Function} listener
|
||||
* The listener function that processes the message.
|
||||
*/
|
||||
function on(mm, message, listener) {
|
||||
mm.addMessageListener(MESSAGE_PREFIX + message, listener);
|
||||
}
|
||||
exports.on = on;
|
||||
|
||||
/**
|
||||
* Removes a message `listener` for the specified `message` on the given
|
||||
* message manager.
|
||||
* @param {nsIMessageListenerManager} mm
|
||||
* The Message Manager
|
||||
* @param {String} message
|
||||
* The message. It will be prefixed with the constant `MESSAGE_PREFIX`
|
||||
* @param {Function} listener
|
||||
* The listener function that processes the message.
|
||||
*/
|
||||
function off(mm, message, listener) {
|
||||
mm.removeMessageListener(MESSAGE_PREFIX + message, listener);
|
||||
}
|
||||
exports.off = off;
|
||||
|
||||
/**
|
||||
* Resolves a promise the next time the specified `message` is sent over the
|
||||
* given message manager.
|
||||
* @param {nsIMessageListenerManager} mm
|
||||
* The Message Manager
|
||||
* @param {String} message
|
||||
* The message. It will be prefixed with the constant `MESSAGE_PREFIX`
|
||||
* @returns {Promise}
|
||||
* A promise that is resolved when the given message is emitted.
|
||||
*/
|
||||
function once(mm, message) {
|
||||
let { resolve, promise } = defer();
|
||||
|
||||
on(mm, message, function onMessage({data}) {
|
||||
off(mm, message, onMessage);
|
||||
resolve(data);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
exports.once = once;
|
||||
|
||||
/**
|
||||
* Asynchronously emit a `message` to the listeners of the given message
|
||||
* manager.
|
||||
*
|
||||
* @param {nsIMessageListenerManager} mm
|
||||
* The Message Manager
|
||||
* @param {String} message
|
||||
* The message. It will be prefixed with the constant `MESSAGE_PREFIX`.
|
||||
* @param {Object} data
|
||||
* A JSON object containing data to be delivered to the listeners.
|
||||
*/
|
||||
function emit(mm, message, data) {
|
||||
mm.sendAsyncMessage(MESSAGE_PREFIX + message, data);
|
||||
}
|
||||
exports.emit = emit;
|
||||
|
||||
/**
|
||||
* Asynchronously send a "request" over the given message manager, and returns
|
||||
* a promise that is resolved when the request is complete.
|
||||
*
|
||||
* @param {nsIMessageListenerManager} mm
|
||||
* The Message Manager
|
||||
* @param {String} message
|
||||
* The message. It will be prefixed with the constant `MESSAGE_PREFIX`, and
|
||||
* also suffixed with `REQUEST_DONE_SUFFIX` for the reply.
|
||||
* @param {Object} data
|
||||
* A JSON object containing data to be delivered to the listeners.
|
||||
* @returns {Promise}
|
||||
* A promise that is resolved when the request is done.
|
||||
*/
|
||||
function request(mm, message, data) {
|
||||
let done = once(mm, message + REQUEST_DONE_SUFFIX);
|
||||
|
||||
emit(mm, message, data);
|
||||
|
||||
return done;
|
||||
}
|
||||
exports.request = request;
|
||||
21
devtools/client/responsive.html/utils/enum.js
Normal file
21
devtools/client/responsive.html/utils/enum.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* 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";
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Create a simple enum-like object with keys mirrored to values from an array.
|
||||
* This makes comparison to a specfic value simpler without having to repeat and
|
||||
* mis-type the value.
|
||||
*/
|
||||
createEnum(array, target = {}) {
|
||||
for (let key of array) {
|
||||
target[key] = key;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
};
|
||||
16
devtools/client/responsive.html/utils/l10n.js
Normal file
16
devtools/client/responsive.html/utils/l10n.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* 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 { LocalizationHelper } = require("devtools/shared/l10n");
|
||||
const STRINGS_URI = "devtools/client/locales/responsive.properties";
|
||||
const L10N = new LocalizationHelper(STRINGS_URI);
|
||||
|
||||
module.exports = {
|
||||
getStr: (...args) => L10N.getStr(...args),
|
||||
getFormatStr: (...args) => L10N.getFormatStr(...args),
|
||||
getFormatStrWithNumbers: (...args) => L10N.getFormatStrWithNumbers(...args),
|
||||
numberWithDecimals: (...args) => L10N.numberWithDecimals(...args),
|
||||
};
|
||||
38
devtools/client/responsive.html/utils/message.js
Normal file
38
devtools/client/responsive.html/utils/message.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* 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 promise = require("promise");
|
||||
|
||||
const REQUEST_DONE_SUFFIX = ":done";
|
||||
|
||||
function wait(win, type) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
let onMessage = event => {
|
||||
if (event.data.type !== type) {
|
||||
return;
|
||||
}
|
||||
win.removeEventListener("message", onMessage);
|
||||
deferred.resolve();
|
||||
};
|
||||
win.addEventListener("message", onMessage);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function post(win, type) {
|
||||
win.postMessage({ type }, "*");
|
||||
}
|
||||
|
||||
function request(win, type) {
|
||||
let done = wait(win, type + REQUEST_DONE_SUFFIX);
|
||||
post(win, type);
|
||||
return done;
|
||||
}
|
||||
|
||||
exports.wait = wait;
|
||||
exports.post = post;
|
||||
exports.request = request;
|
||||
12
devtools/client/responsive.html/utils/moz.build
Normal file
12
devtools/client/responsive.html/utils/moz.build
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
DevToolsModules(
|
||||
'e10s.js',
|
||||
'enum.js',
|
||||
'l10n.js',
|
||||
'message.js',
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue