OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This test is for bizarre things that extensions probably will do. We just | 5 // This test is for bizarre things that extensions probably will do. We just |
6 // need to ensure that behaviour is predictable. | 6 // need to ensure that behaviour is predictable. |
7 | 7 |
8 chrome.test.runTests([ | 8 chrome.test.runTests([ |
9 function accessNonexistentIframe() { | 9 function accessNonexistentIframe() { |
10 var iframe = document.createElement("iframe"); | 10 var iframe = document.createElement("iframe"); |
11 iframe.src = document.location; | 11 iframe.src = document.location; |
12 var iteration = 0; | 12 var iteration = 0; |
13 iframe.addEventListener('load', function() { | 13 iframe.addEventListener('load', function() { |
14 switch (iteration) { | 14 switch (iteration) { |
15 case 0: { | 15 case 0: { |
16 // First test is that chrome.webstore doesn't even get defined if it | 16 // First test is that chrome.app doesn't even get defined if it was |
17 // was never accessed. | 17 // never accessed. |
18 var iframeChrome = iframe.contentWindow.chrome; | 18 var iframeChrome = iframe.contentWindow.chrome; |
19 document.body.removeChild(iframe); | 19 document.body.removeChild(iframe); |
20 chrome.test.assertEq(undefined, iframeChrome.webstore); | 20 chrome.test.assertEq(undefined, iframeChrome.app); |
21 document.body.appendChild(iframe); | 21 document.body.appendChild(iframe); |
22 break; | 22 break; |
23 } | 23 } |
24 case 1: { | 24 case 1: { |
25 // Second test is that it does if accessed before removal. | 25 // Second test is that it does if accessed before removal. |
26 var iframeChrome = iframe.contentWindow.chrome; | 26 var iframeChrome = iframe.contentWindow.chrome; |
27 var iframeChromeWebstore = iframeChrome.webstore; | 27 var iframeChromeApp = iframeChrome.app; |
28 chrome.test.assertTrue(typeof(iframeChromeWebstore) == 'object'); | 28 chrome.test.assertTrue(typeof(iframeChromeApp) == 'object'); |
29 document.body.removeChild(iframe); | 29 document.body.removeChild(iframe); |
30 chrome.test.assertTrue(typeof(iframeChrome.webstore) == 'object'); | 30 chrome.test.assertTrue(typeof(iframeChrome.app) == 'object'); |
31 document.body.appendChild(iframe); | 31 document.body.appendChild(iframe); |
32 break; | 32 break; |
33 } | 33 } |
34 case 2: { | 34 case 2: { |
35 // Third test is that accessing API methods doesn't crash the | 35 // Third test is that accessing API methods doesn't crash the |
36 // renderer if the frame doesn't exist anymore. | 36 // renderer if the frame doesn't exist anymore. |
37 var iframeChromeApp = iframe.contentWindow.chrome.app; | 37 var iframeChromeApp = iframe.contentWindow.chrome.app; |
38 document.body.removeChild(iframe); | 38 document.body.removeChild(iframe); |
39 chrome.test.assertEq(undefined, iframeChromeApp.getDetails()); | 39 chrome.test.assertEq(undefined, iframeChromeApp.getDetails()); |
40 chrome.test.succeed(); | 40 chrome.test.succeed(); |
41 break; | 41 break; |
42 } | 42 } |
43 } | 43 } |
44 iteration++; | 44 iteration++; |
45 }); | 45 }); |
46 document.body.appendChild(iframe); | 46 document.body.appendChild(iframe); |
47 } | 47 } |
48 ]); | 48 ]); |
OLD | NEW |