Commit 035e3b00 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Add regression test for guest view name collision in extension

This tests that an extension background page is able to declare
variables whose names are the same as guest view elements without the
declarations being considered syntax errors.

Bug: 1014385
Change-Id: I5ca92d739fe04fece2078f53e9f5eca4f73b040f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864407Reviewed-by: default avatarJames MacLean <wjmaclean@chromium.org>
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712188}
parent 32ad4bd0
......@@ -4415,3 +4415,24 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, OpenAndCloseDevTools) {
embedder, false /* is_docked */);
DevToolsWindowTesting::CloseDevToolsWindowSync(devtools);
}
// Regression test for https://crbug.com/1014385
// We load an extension whose background page attempts to declare variables with
// names that are the same as guest view types. The declarations should not be
// syntax errors.
using GuestViewExtensionNameCollisionTest = extensions::ExtensionBrowserTest;
IN_PROC_BROWSER_TEST_F(GuestViewExtensionNameCollisionTest,
GuestViewNamesDoNotCollideWithExtensions) {
ExtensionTestMessageListener loaded_listener("LOADED", false);
const extensions::Extension* extension =
LoadExtension(test_data_dir_.AppendASCII(
"platform_apps/web_view/no_extension_name_collision"));
ASSERT_TRUE(loaded_listener.WaitUntilSatisfied());
const std::string script =
"window.domAutomationController.send("
" window.testPassed ? 'PASSED' : 'FAILED');";
const std::string test_passed =
ExecuteScriptInBackgroundPage(extension->id(), script);
EXPECT_EQ("PASSED", test_passed);
}
<!--
* Copyright 2019 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.
-->
<html>
<head>
<script src="start_test.js"></script>
<script src="background.js"></script>
</head>
<body>
</body>
</html>
// Copyright 2019 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.
// Regression test for https://crbug.com/1014385
// Since this is an extension's background page, the following lines should not
// throw a syntax error due to redeclaration.
const ExtensionOptions = {};
const AppView = {};
const WebView = {};
window.testPassed = true;
{
"name": "no_extension_name_collision",
"description": "Test that an extension can use names also used by guest views without naming collisions",
"manifest_version": 2,
"version": "1",
"background": {
"page": "background.html"
},
"permissions": [ "background" ]
}
// Copyright 2019 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.
// We need to signal the start of the test from a different file because when
// the test fails, we have a syntax error in background.js.
chrome.test.sendMessage('LOADED');
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