Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: chrome/test/data/extensions/api_test/crazy_extension/background.js

Issue 12693008: Prevent ObjectBackedNativeHandler from calling itself once invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+ }
+]);
« no previous file with comments | « chrome/renderer/extensions/v8_schema_registry.cc ('k') | chrome/test/data/extensions/api_test/crazy_extension/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698