Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/test/data/extensions/api_test/connect/test.html

Issue 341025: Change the extension.onRequest even to include the sender info. (Closed)
Patch Set: fix args Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/connect/page.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <script> 1 <script>
2 chrome.test.runTests([ 2 chrome.test.runTests([
3 // Tests receiving a request from a content script and responding. 3 // Tests receiving a request from a content script and responding.
4 function onRequest() { 4 function onRequest() {
5 chrome.extension.onRequest.addListener(function(request, sendResponse) { 5 chrome.extension.onRequest.addListener(
6 if (request.step == 1) { 6 function(request, sender, sendResponse) {
7 // Step 1: Page should send another request for step 2. 7 chrome.test.assertTrue("url" in sender.tab, "no tab available.");
8 sendResponse({nextStep: true}); 8 chrome.test.assertEq(sender.id, location.host);
9 } else { 9 if (request.step == 1) {
10 // Step 2. 10 // Step 1: Page should send another request for step 2.
11 chrome.test.assertEq(request.step, 2); 11 sendResponse({nextStep: true});
12 sendResponse({}); 12 } else {
13 chrome.test.succeed(); 13 // Step 2.
14 } 14 chrome.test.assertEq(request.step, 2);
15 }); 15 sendResponse({});
16 chrome.test.succeed();
17 }
18 });
16 }, 19 },
17 // Tests sending a request to a tab and receiving a response. 20 // Tests sending a request to a tab and receiving a response.
18 function sendRequest() { 21 function sendRequest() {
19 chrome.tabs.getSelected(null, function(tab) { 22 chrome.tabs.getSelected(null, function(tab) {
20 chrome.test.log('Selected tab: ' + tab.url); 23 chrome.test.log("Selected tab: " + tab.url);
21 chrome.tabs.sendRequest(tab.id, {step2: 1}, function(response) { 24 chrome.tabs.sendRequest(tab.id, {step2: 1}, function(response) {
22 chrome.test.assertTrue(response.success); 25 chrome.test.assertTrue(response.success);
23 chrome.test.succeed(); 26 chrome.test.succeed();
24 }); 27 });
25 }); 28 });
26 } 29 }
27 ]); 30 ]);
28 31
29 chrome.test.log("Creating tab..."); 32 chrome.test.log("Creating tab...");
30 chrome.tabs.create({ 33 chrome.tabs.create({
31 url: "http://localhost:1337/files/extensions/test_file.html" 34 url: "http://localhost:1337/files/extensions/test_file.html"
32 }); 35 });
33 </script> 36 </script>
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/connect/page.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698