-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdevtools.js
More file actions
55 lines (46 loc) · 1.35 KB
/
Copy pathdevtools.js
File metadata and controls
55 lines (46 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Create a connection to the background page
var backgroundPageConnection = chrome.runtime.connect({
name: "panel"
});
var tab_id = chrome.devtools.inspectedWindow.tabId;
backgroundPageConnection.postMessage({
name: 'init',
tabId: chrome.devtools.inspectedWindow.tabId
});
chrome.devtools.panels.create("Codeception TestTools", null, "../html/panel.html", function(extensionPanel) {
var _window;
var steps;
extensionPanel.onShown.addListener(function tmp(panelWindow) {
extensionPanel.onShown.removeListener(tmp); // Run once
_window = panelWindow;
_window._postMessage = function(obj) {
backgroundPageConnection.postMessage({
"name": "postMessage",
"tabId": tab_id,
"object": obj
});
};
// Initialize
if (steps) {
_window.setSteps(steps);
} else {
_window._postMessage({
"method": "getSteps"
});
}
chrome.devtools.inspectedWindow.eval(
"window.location.pathname",
function(result) {
_window.setPathname(result);
}
);
});
backgroundPageConnection.onMessage.addListener(function (message) {
if (_window) {
_window.setSteps(message);
} else {
steps = message;
}
});
}
);