forked from mirrors/gecko-dev
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35962 --HG-- extra : source : c0948f31e520ca087279cf429ca5f1db5a8341b8
32 lines
1.1 KiB
JavaScript
32 lines
1.1 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/. */
|
|
|
|
// receives result from benchmark and relays onto our background runner
|
|
|
|
function receiveMessage(event) {
|
|
raptorLog("raptor benchmark received message");
|
|
raptorLog(event.data);
|
|
// raptor benchmark message data [0] is raptor tag, [1] is benchmark
|
|
// name, and the rest is actual benchmark results that we want to fw
|
|
if (event.data[0] == "raptor-benchmark") {
|
|
sendResult(event.data[1], event.data.slice(2));
|
|
}
|
|
}
|
|
|
|
function sendResult(_type, _value) {
|
|
// send result back to background runner script
|
|
raptorLog(`sending result back to runner: ${_type} ${_value}`);
|
|
chrome.runtime.sendMessage({ type: _type, value: _value }, function(
|
|
response
|
|
) {
|
|
raptorLog(response.text);
|
|
});
|
|
}
|
|
|
|
function raptorLog(logText) {
|
|
console.log(`[raptor-benchmarkjs] ${logText}`);
|
|
}
|
|
|
|
raptorLog("raptor benchmark content loaded");
|
|
window.addEventListener("message", receiveMessage);
|