Commit 47e79040 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions Bindings] Move CrazyExtensionTest.Crazy to bindings apitests

CrazyExtensionTest.Crazy tests the result of calling into the app API
of a removed context. Conceptually, this is very similar to other
extension bindings API tests, and would benefit from constant tree
coverage with both JS and native bindings. Move the test to the
ExtensionBindingsApiTest suite, and have it run with both JS and native
bindings.

Additionally, the behavior for native and JS bindings is slightly
different when accessing invalidated contexts' APIs: Native bindings
throw an error, whereas JS bindings do not. Adjust the test expectations
accordingly.

Also rename the test to something slightly more descriptive
(s/Crazy/UseAppAPIAfterFrameRemoval).

Bug: 653596
Test: browser_tests --gtest_filter=*UseAppAPIAfterFrameRemoval*

Change-Id: Ic9c1615eda03320262d04c9760bc7879b2af78c5
Reviewed-on: https://chromium-review.googlesource.com/898397Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534103}
parent dc0c2db8
// 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.
#include "chrome/browser/extensions/extension_apitest.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
class CrazyExtensionTest : public ExtensionApiTest {
};
IN_PROC_BROWSER_TEST_F(CrazyExtensionTest, Crazy) {
ASSERT_TRUE(RunExtensionTest("crazy_extension"));
}
} // namespace extensions
......@@ -427,6 +427,12 @@ IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, UseAPIsAfterContextRemoval) {
EXPECT_TRUE(RunExtensionTest("bindings/invalidate_context")) << message_;
}
// TODO(devlin): Can this be combined with
// ExtensionBindingsApiTest.UseAPIsAfterContextRemoval?
IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, UseAppAPIAfterFrameRemoval) {
ASSERT_TRUE(RunExtensionTest("crazy_extension"));
}
// Run core bindings API tests with both native and JS-based bindings. This
// ensures we have some minimum level of coverage while in the experimental
// phase, when native bindings may be enabled on trunk but not at 100% stable.
......
......@@ -1212,7 +1212,6 @@ test("browser_tests") {
"../browser/extensions/content_script_apitest.cc",
"../browser/extensions/content_security_policy_apitest.cc",
"../browser/extensions/content_verifier_browsertest.cc",
"../browser/extensions/crazy_extension_browsertest.cc",
"../browser/extensions/cross_origin_xhr_apitest.cc",
"../browser/extensions/crx_installer_browsertest.cc",
"../browser/extensions/docs/examples/apps/calculator_browsertest.cc",
......
......@@ -42,7 +42,17 @@ chrome.test.runTests([
// renderer if the frame doesn't exist anymore.
var iframeChromeApp = iframe.contentWindow.chrome.app;
document.body.removeChild(iframe);
chrome.test.assertEq(undefined, iframeChromeApp.getDetails());
var getDetailsResult;
// Note: native bindings throw an error when accessed after
// invalidation (to let the script know something when wrong); JS
// bindings just return undefined.
try {
getDetailsResult = iframeChromeApp.getDetails();
} catch (e) {
chrome.test.assertTrue(e.message.includes('context invalidated'),
e.message);
}
chrome.test.assertEq(undefined, getDetailsResult);
chrome.test.succeed();
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment