OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var assertEq = chrome.test.assertEq; | 5 var assertEq = chrome.test.assertEq; |
6 var assertTrue = chrome.test.assertTrue; | 6 var assertTrue = chrome.test.assertTrue; |
7 var numReceivedRequests = 0; | 7 var numReceivedRequests = 0; |
8 var relativePath = 'files/extensions/api_test/executescript/permissions/'; | 8 var relativePath = 'files/extensions/api_test/executescript/permissions/'; |
9 var testFile = relativePath + 'empty.html'; | 9 var testFile = relativePath + 'empty.html'; |
10 var testFileFrames = relativePath + 'frames.html'; | 10 var testFileFrames = relativePath + 'frames.html'; |
(...skipping 24 matching lines...) Expand all Loading... |
35 function() { | 35 function() { |
36 chrome.tabs.create({url: fixPort('http://c.com:PORT/') + testFile}); | 36 chrome.tabs.create({url: fixPort('http://c.com:PORT/') + testFile}); |
37 onTabLoaded = function(tab) { | 37 onTabLoaded = function(tab) { |
38 onTabLoaded = null; | 38 onTabLoaded = null; |
39 numReceivedRequests = 0; | 39 numReceivedRequests = 0; |
40 chrome.tabs.update( | 40 chrome.tabs.update( |
41 tab.id, {url: fixPort('http://a.com:PORT/') + testFile}); | 41 tab.id, {url: fixPort('http://a.com:PORT/') + testFile}); |
42 chrome.tabs.executeScript(tab.id, {file: 'script.js'}); | 42 chrome.tabs.executeScript(tab.id, {file: 'script.js'}); |
43 window.setTimeout(function() { | 43 window.setTimeout(function() { |
44 assertEq(0, numReceivedRequests); | 44 assertEq(0, numReceivedRequests); |
45 chrome.test.runNextTest(); | 45 chrome.test.succeed(); |
46 }, 4000); | 46 }, 4000); |
47 }; | 47 }; |
48 }, | 48 }, |
49 | 49 |
50 // Inject into all frames. This should only affect frames we have | 50 // Inject into all frames. This should only affect frames we have |
51 // access to. This page has three subframes, one each from a.com, | 51 // access to. This page has three subframes, one each from a.com, |
52 // b.com, and c.com. We have access to two of those, plus the root | 52 // b.com, and c.com. We have access to two of those, plus the root |
53 // frame, so we should get three responses. | 53 // frame, so we should get three responses. |
54 function() { | 54 function() { |
55 chrome.tabs.create( | 55 chrome.tabs.create( |
56 {url: fixPort('http://a.com:PORT/') + testFileFrames}); | 56 {url: fixPort('http://a.com:PORT/') + testFileFrames}); |
57 onTabLoaded = function(tab) { | 57 onTabLoaded = function(tab) { |
58 numReceivedRequests = 0; | 58 numReceivedRequests = 0; |
59 chrome.tabs.executeScript(tab.id, | 59 chrome.tabs.executeScript(tab.id, |
60 {file: 'script.js', allFrames: true}); | 60 {file: 'script.js', allFrames: true}); |
61 window.setTimeout(function() { | 61 window.setTimeout(function() { |
62 chrome.test.assertEq(3, numReceivedRequests); | 62 chrome.test.assertEq(3, numReceivedRequests); |
63 chrome.test.runNextTest(); | 63 chrome.test.succeed(); |
64 }, 4000); | 64 }, 4000); |
65 }; | 65 }; |
66 } | 66 } |
67 ]); | 67 ]); |
68 | 68 |
69 }); | 69 }); |
OLD | NEW |