mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 00:08:39 +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
105
toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample/bootstrap.js
vendored
Normal file
105
toolkit/components/perfmonitoring/tests/browser/browser_Addons_sample/bootstrap.js
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Sample for browser_AddonWatcher.js
|
||||
|
||||
"use strict";
|
||||
|
||||
const {utils: Cu, classes: Cc, interfaces: Ci} = Components;
|
||||
|
||||
const TOPIC_BURNCPU = "test-addonwatcher-burn-some-cpu";
|
||||
const TOPIC_BURNCPOW = "test-addonwatcher-burn-some-cpow";
|
||||
const TOPIC_BURNCONTENTCPU = "test-addonwatcher-burn-some-content-cpu";
|
||||
const TOPIC_READY = "test-addonwatcher-ready";
|
||||
|
||||
const MESSAGE_BURNCPOW = "test-addonwatcher-cpow:init";
|
||||
const URL_FRAMESCRIPT = "chrome://addonwatcher-test/content/framescript.js";
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm", this);
|
||||
const { setTimeout } = Cu.import("resource://gre/modules/Timer.jsm", {});
|
||||
Cu.import("resource://gre/modules/Task.jsm", this);
|
||||
|
||||
let globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
/**
|
||||
* Spend some time using CPU.
|
||||
*/
|
||||
function burnCPU() {
|
||||
let ignored = [];
|
||||
let start = Date.now();
|
||||
let i = 0;
|
||||
while (Date.now() - start < 1000) {
|
||||
ignored[i++ % 2] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Spend some time in CPOW.
|
||||
*/
|
||||
function burnCPOW() {
|
||||
gBurnCPOW();
|
||||
}
|
||||
let gBurnCPOW = null;
|
||||
|
||||
function burnContentCPU() {
|
||||
setTimeout(() => { try {
|
||||
gBurnContentCPU()
|
||||
} catch (ex) {
|
||||
dump(`test-addon error: ${ex}\n`);
|
||||
} }, 0);
|
||||
}
|
||||
let gBurnContentCPU = null;
|
||||
|
||||
let gTab = null;
|
||||
let gTabBrowser = null;
|
||||
|
||||
function startup() {
|
||||
Services.obs.addObserver(burnCPU, TOPIC_BURNCPU, false);
|
||||
Services.obs.addObserver(burnCPOW, TOPIC_BURNCPOW, false);
|
||||
Services.obs.addObserver(burnContentCPU, TOPIC_BURNCONTENTCPU, false);
|
||||
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
let win = windows.getNext();
|
||||
gTabBrowser = win.gBrowser;
|
||||
gTab = gTabBrowser.addTab("about:robots");
|
||||
gBurnContentCPU = function() {
|
||||
gTab.linkedBrowser.messageManager.sendAsyncMessage("test-addonwatcher-burn-some-content-cpu", {});
|
||||
}
|
||||
|
||||
gTab.linkedBrowser.messageManager.loadFrameScript(URL_FRAMESCRIPT, false);
|
||||
globalMM.loadFrameScript(URL_FRAMESCRIPT, false);
|
||||
|
||||
if (Services.appinfo.browserTabsRemoteAutostart) {
|
||||
// This profile has e10s enabled, which means we'll want to
|
||||
// test CPOW traffic.
|
||||
globalMM.addMessageListener("test-addonwatcher-cpow:init", function waitForCPOW(msg) {
|
||||
if (Components.utils.isCrossProcessWrapper(msg.objects.burnCPOW)) {
|
||||
gBurnCPOW = msg.objects.burnCPOW;
|
||||
globalMM.removeMessageListener("test-addonwatcher-cpow:init", waitForCPOW);
|
||||
Services.obs.notifyObservers(null, TOPIC_READY, null);
|
||||
} else {
|
||||
Cu.reportError("test-addonwatcher-cpow:init didn't give us a CPOW! Expect timeouts.");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// e10s is not enabled, so a CPOW is not necessary - we can report ready
|
||||
// right away.
|
||||
Services.obs.notifyObservers(null, TOPIC_READY, null);
|
||||
}
|
||||
}
|
||||
|
||||
function shutdown() {
|
||||
Services.obs.removeObserver(burnCPU, TOPIC_BURNCPU);
|
||||
Services.obs.removeObserver(burnCPOW, TOPIC_BURNCPOW);
|
||||
Services.obs.removeObserver(burnContentCPU, TOPIC_BURNCONTENTCPU);
|
||||
gTabBrowser.removeTab(gTab);
|
||||
}
|
||||
|
||||
function install() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
function uninstall() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
echo "Rebuilding browser_Addons_sample.xpi..."
|
||||
zip -r ../browser_Addons_sample.xpi .
|
||||
echo "
|
||||
Done! Don't forget to sign it: https://wiki.mozilla.org/EngineeringProductivity/HowTo/SignExtensions"
|
||||
|
|
@ -0,0 +1 @@
|
|||
content addonwatcher-test content/
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/* 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";
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function burnCPOW(msg) {
|
||||
dump(`Addon: content burnCPU start ${Math.sin(Math.random())}\n`);
|
||||
let start = content.performance.now();
|
||||
let ignored = [];
|
||||
while (content.performance.now() - start < 5000) {
|
||||
ignored[ignored.length % 2] = ignored.length;
|
||||
}
|
||||
dump(`Addon: content burnCPU done: ${content.performance.now() - start}\n`);
|
||||
}
|
||||
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
sendAsyncMessage("test-addonwatcher-cpow:init", {}, {burnCPOW});
|
||||
}
|
||||
|
||||
addMessageListener("test-addonwatcher-burn-some-content-cpu", burnCPOW);
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>addonwatcher-test@mozilla.com</em:id>
|
||||
<em:version>1.1</em:version>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>0.3</em:minVersion>
|
||||
<em:maxVersion>*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>toolkit@mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<em:bootstrap>true</em:bootstrap>
|
||||
|
||||
<em:name>Sample for browser_AddonWatcher.js</em:name>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
||||
Loading…
Add table
Add a link
Reference in a new issue