This commit is contained in:
C. Naoto Abreu Takemura 2019-02-06 02:40:09 -08:00
Родитель ff013aa3a0
Коммит a8d9b56f1d
1 изменённых файлов: 0 добавлений и 37 удалений

Просмотреть файл

@ -1,37 +0,0 @@
class MezzuriteInspector {
static isMezzuritePresentAsync () {
const expression = `window.mezzurite != null`;
return new Promise(function (resolve, reject) {
chrome.devtools.inspectedWindow.eval(expression, (result, exceptionInfo) => {
if (exceptionInfo !== undefined) {
reject(Error(exceptionInfo));
} else {
resolve(result); // Return the object, which can be undefined. Let caller handle it.
}
});
});
}
/**
* Set up an event listener to grab Mezzurite timing events forwarded
* by the content script and execute a callback method.
*/
static listenForTimingEvents (callback) {
const backgroundPageConnection = chrome.runtime.connect({
name: 'devtools-page'
});
backgroundPageConnection.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === 'timing') {
callback(message.payload);
}
});
backgroundPageConnection.postMessage({
action: 'init',
tabId: chrome.devtools.inspectedWindow.tabId
});
}
}
export default MezzuriteInspector;