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