blob: 31868b431ac9844a12256234d2144dd5d2f7b03d (
plain)
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
|
<script>
chrome.test.runTests([
// Tests receiving a request from a content script and responding.
function onRequest() {
chrome.extension.onRequest.addListener(function(request, sendResponse) {
if (request.step == 1) {
// Step 1: Page should send another request for step 2.
sendResponse({nextStep: true});
} else {
// Step 2.
chrome.test.assertEq(request.step, 2);
sendResponse({});
chrome.test.succeed();
}
});
},
// Tests sending a request to a tab and receiving a response.
function sendRequest() {
chrome.tabs.getSelected(null, function(tab) {
chrome.test.log('Selected tab: ' + tab.url);
chrome.tabs.sendRequest(tab.id, {step2: 1}, function(response) {
chrome.test.assertTrue(response.success);
chrome.test.succeed();
});
});
}
]);
chrome.test.log("Creating tab...");
chrome.tabs.create({
url: "http://localhost:1337/files/extensions/test_file.html"
});
</script>
|