| 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 numPings = 0; | 5 var numPings = 0; |
| 6 var base_url; |
| 7 |
| 6 chrome.extension.onRequest.addListener(function(data) { | 8 chrome.extension.onRequest.addListener(function(data) { |
| 7 if (data != "ping") | 9 if (data != "ping") |
| 8 chrome.test.fail("Unexpected request: " + JSON.stringify(data)); | 10 chrome.test.fail("Unexpected request: " + JSON.stringify(data)); |
| 9 | 11 |
| 10 if (++numPings == 2) | 12 if (++numPings == 2) { |
| 13 // Navigate the iframe to another page and check that the content script is |
| 14 // also injected into that page. |
| 15 document.querySelector("iframe").src = |
| 16 base_url + "test_file_with_body.html"; |
| 17 } else if (numPings == 3) { |
| 11 chrome.test.notifyPass(); | 18 chrome.test.notifyPass(); |
| 19 } |
| 12 }); | 20 }); |
| 13 | 21 |
| 14 chrome.test.getConfig(function(config) { | 22 chrome.test.getConfig(function(config) { |
| 15 var test_file_url = "http://localhost:PORT/extensions/test_file.html" | 23 base_url = "http://localhost:PORT/extensions/" |
| 16 .replace(/PORT/, config.testServer.port); | 24 .replace(/PORT/, config.testServer.port); |
| 25 var test_file_url = base_url + "test_file.html"; |
| 17 | 26 |
| 18 // Add a window. | 27 // Add a window. |
| 19 var w = window.open(test_file_url); | 28 var w = window.open(test_file_url); |
| 20 | 29 |
| 21 // Add an iframe. | 30 // Add an iframe. |
| 22 var iframe = document.createElement("iframe"); | 31 var iframe = document.createElement("iframe"); |
| 23 iframe.src = test_file_url; | 32 iframe.src = test_file_url; |
| 24 document.getElementById("iframeContainer").appendChild(iframe); | 33 document.getElementById("iframeContainer").appendChild(iframe); |
| 25 }); | 34 }); |
| OLD | NEW |