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.
5 // This test is for bizarre things that extensions probably will do. We just
6 // need to ensure that behaviour is predictable.
9 function accessNonexistentIframe() {
10 var iframe
= document
.createElement("iframe");
11 iframe
.src
= document
.location
;
13 iframe
.addEventListener('load', function() {
16 // First test is that chrome.app doesn't even get defined if it was
18 var iframeChrome
= iframe
.contentWindow
.chrome
;
19 document
.body
.removeChild(iframe
);
20 chrome
.test
.assertEq(undefined, iframeChrome
.app
);
21 document
.body
.appendChild(iframe
);
25 // Second test is that it does if accessed before removal.
26 var iframeChrome
= iframe
.contentWindow
.chrome
;
27 var iframeChromeApp
= iframeChrome
.app
;
28 chrome
.test
.assertTrue(typeof(iframeChromeApp
) == 'object');
29 document
.body
.removeChild(iframe
);
30 chrome
.test
.assertTrue(typeof(iframeChrome
.app
) == 'object');
31 document
.body
.appendChild(iframe
);
35 // Third test is that accessing API methods doesn't crash the
36 // renderer if the frame doesn't exist anymore.
37 var iframeChromeApp
= iframe
.contentWindow
.chrome
.app
;
38 document
.body
.removeChild(iframe
);
39 chrome
.test
.assertEq(undefined, iframeChromeApp
.getDetails());
40 chrome
.test
.succeed();
46 document
.body
.appendChild(iframe
);