forked from ebrehault/resurrectio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
41 lines (41 loc) · 1.22 KB
/
background.js
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
var testcase_items = new Array();
var active = false;
var empty = true;
var tab_id = null;
console.log('init');
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log(request);
if (request.action == "append") {
testcase_items[testcase_items.length] = request.obj;
empty = false;
sendResponse({});
}
if (request.action == "poke") {
testcase_items[testcase_items.length - 1] = request.obj;
sendResponse({});
}
if (request.action == "get_status") {
sendResponse({'active': active, 'empty': empty});
}
if (request.action == "start") {
if(!active) {
active = true;
empty = true;
testcase_items = new Array();
tab_id = request.recorded_tab;
chrome.tabs.update(tab_id, {url: request.start_url}, function(tab) {
alert("You are now recording your test sequence.");
chrome.tabs.sendMessage(tab_id, {action: "open", 'url': request.start_url});
sendResponse({start: true});
});
}
}
if (request.action == "stop") {
active = false;
chrome.tabs.sendMessage(tab_id, {action: "stop"});
sendResponse({});
}
if (request.action == "get_items") {
sendResponse({'items': testcase_items});
}
});