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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 ]);
OLDNEW
« 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