| Index: chrome/test/data/extensions/api_test/crazy_extension/background.js
|
| diff --git a/chrome/test/data/extensions/api_test/crazy_extension/background.js b/chrome/test/data/extensions/api_test/crazy_extension/background.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ab7b3016badeefc12c62735d2da46ee0f2462b7e
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/crazy_extension/background.js
|
| @@ -0,0 +1,54 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// This test is for bizarre things that extensions probably will do. We just
|
| +// need to ensure that behaviour is predictable.
|
| +
|
| +chrome.test.runTests([
|
| + function accessNonexistentIframe() {
|
| + var iframe = document.createElement("iframe");
|
| + iframe.src = document.location;
|
| + var iteration = 0;
|
| + iframe.addEventListener('load', function() {
|
| + switch (iteration) {
|
| + case 0: {
|
| + // First test is that chrome.webstore doesn't even get defined if it
|
| + // was never accessed.
|
| + var iframeChrome = iframe.contentWindow.chrome;
|
| + document.body.removeChild(iframe);
|
| + chrome.test.assertEq(undefined, iframeChrome.webstore);
|
| + document.body.appendChild(iframe);
|
| + break;
|
| + }
|
| + case 1: {
|
| + // Second test is that it does if accessed before removal.
|
| + var iframeChrome = iframe.contentWindow.chrome;
|
| + var iframeChromeWebstore = iframeChrome.webstore;
|
| + chrome.test.assertTrue(typeof(iframeChromeWebstore) == 'object');
|
| + document.body.removeChild(iframe);
|
| + chrome.test.assertTrue(typeof(iframeChrome.webstore) == 'object');
|
| + document.body.appendChild(iframe);
|
| + break;
|
| + }
|
| + case 2: {
|
| + // Third test is that calling frame-dependent methods doesn't crash
|
| + // the renderer if the frame doesn't exist anymore.
|
| + var iframeChromeApp = iframe.contentWindow.chrome.app;
|
| + document.body.removeChild(iframe);
|
| + var exception = null;
|
| + try {
|
| + iframeChromeApp.getDetails();
|
| + } catch (e) {
|
| + exception = e;
|
| + }
|
| + chrome.test.assertEq("Extension view no longer exists", exception);
|
| + chrome.test.succeed();
|
| + break;
|
| + }
|
| + }
|
| + iteration++;
|
| + });
|
| + document.body.appendChild(iframe);
|
| + }
|
| +]);
|
|
|