Remove js-webui bindings test for content/test
We are deprecating the closure-webui bindings. The ts test already coveres everything that the closure-webui tests covered. on CrOS targets. Bug: 384098175 Change-Id: I660094b951229e150b5e6ca81dd854cd10950e86 Tested: manually verified that the ts webui bindings are still running Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6119189 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Rebekah Potter <rbpotter@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Fred Shih <ffred@chromium.org> Cr-Commit-Position: refs/heads/main@{#1401575}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
732d7dfdf6
commit
b3bb9c5ca1
@ -50,47 +50,12 @@
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "third_party/blink/public/common/chrome_debug_urls.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
#include "content/test/data/web_ui_test.test-mojom.h"
|
||||
#include "content/test/data/web_ui_test_types.test-mojom.h"
|
||||
#endif
|
||||
|
||||
namespace content {
|
||||
namespace {
|
||||
|
||||
const char kMojoWebUiHost[] = "mojo-web-ui";
|
||||
const char kMojoWebUiTsHost[] = "mojo-web-ui-ts";
|
||||
const char kDummyWebUiHost[] = "dummy-web-ui";
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
class WebUIMojoTestCacheImpl : public mojom::WebUIMojoTestCache {
|
||||
public:
|
||||
explicit WebUIMojoTestCacheImpl(
|
||||
mojo::PendingReceiver<mojom::WebUIMojoTestCache> receiver)
|
||||
: receiver_(this, std::move(receiver)) {}
|
||||
|
||||
~WebUIMojoTestCacheImpl() override = default;
|
||||
|
||||
// mojom::WebUIMojoTestCache overrides:
|
||||
void Put(const GURL& url, const std::string& contents) override {
|
||||
cache_[url] = contents;
|
||||
}
|
||||
|
||||
void GetAll(GetAllCallback callback) override {
|
||||
std::vector<mojom::CacheItemPtr> items;
|
||||
for (const auto& entry : cache_)
|
||||
items.push_back(mojom::CacheItem::New(entry.first, entry.second));
|
||||
std::move(callback).Run(std::move(items));
|
||||
}
|
||||
|
||||
private:
|
||||
mojo::Receiver<mojom::WebUIMojoTestCache> receiver_;
|
||||
std::map<GURL, std::string> cache_;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Duplicate for the TypeScript version of the test. We can't re-use because
|
||||
// the TS interface has to be named differently to avoid conflicting symbols.
|
||||
class WebUITsMojoTestCacheImpl : public mojom::WebUITsMojoTestCache {
|
||||
public:
|
||||
explicit WebUITsMojoTestCacheImpl(
|
||||
@ -161,18 +126,6 @@ class TestWebUIController : public WebUIController {
|
||||
{BindingsPolicyValue::kMojoWebUi}))
|
||||
: WebUIController(web_ui) {
|
||||
web_ui->SetBindings(bindings);
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
{
|
||||
WebUIDataSource* data_source = WebUIDataSource::CreateAndAdd(
|
||||
web_ui->GetWebContents()->GetBrowserContext(), kMojoWebUiHost);
|
||||
data_source->OverrideContentSecurityPolicy(
|
||||
network::mojom::CSPDirectiveName::ScriptSrc,
|
||||
"script-src chrome://resources 'self' 'unsafe-eval';");
|
||||
data_source->DisableTrustedTypesCSP();
|
||||
data_source->AddResourcePaths(kWebUiMojoTestResources);
|
||||
data_source->AddResourcePath("", IDR_WEB_UI_MOJO_HTML);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
WebUIDataSource* data_source = WebUIDataSource::CreateAndAdd(
|
||||
web_ui->GetWebContents()->GetBrowserContext(), kMojoWebUiTsHost);
|
||||
@ -199,35 +152,20 @@ class TestWebUIController : public WebUIController {
|
||||
TestWebUIController& operator=(const TestWebUIController&) = delete;
|
||||
|
||||
protected:
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
std::unique_ptr<WebUIMojoTestCacheImpl> cache_;
|
||||
#endif
|
||||
std::unique_ptr<WebUITsMojoTestCacheImpl> ts_cache_;
|
||||
};
|
||||
|
||||
// TestWebUIController that can bind a WebUIMojoTestCache or
|
||||
// WebUITsMojoTestCache interface when requested by the page. Uses asserts to
|
||||
// ensure only one of the two is created for each test.
|
||||
// TestWebUIController that can bind a WebUITsMojoTestCache interface when
|
||||
// requested by the page.
|
||||
class CacheTestWebUIController : public TestWebUIController {
|
||||
public:
|
||||
explicit CacheTestWebUIController(WebUI* web_ui)
|
||||
: TestWebUIController(web_ui) {}
|
||||
~CacheTestWebUIController() override = default;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
void BindInterface(
|
||||
mojo::PendingReceiver<mojom::WebUIMojoTestCache> receiver) {
|
||||
cache_ = std::make_unique<WebUIMojoTestCacheImpl>(std::move(receiver));
|
||||
ASSERT_FALSE(ts_cache_);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BindInterface(
|
||||
mojo::PendingReceiver<mojom::WebUITsMojoTestCache> receiver) {
|
||||
ts_cache_ = std::make_unique<WebUITsMojoTestCacheImpl>(std::move(receiver));
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
ASSERT_FALSE(cache_);
|
||||
#endif
|
||||
}
|
||||
|
||||
WEB_UI_CONTROLLER_TYPE_DECL();
|
||||
@ -317,17 +255,12 @@ class TestWebUIContentBrowserClient
|
||||
void RegisterBrowserInterfaceBindersForFrame(
|
||||
RenderFrameHost* render_frame_host,
|
||||
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override {
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
RegisterWebUIControllerInterfaceBinder<mojom::WebUIMojoTestCache,
|
||||
CacheTestWebUIController>(map);
|
||||
#endif
|
||||
RegisterWebUIControllerInterfaceBinder<mojom::WebUITsMojoTestCache,
|
||||
CacheTestWebUIController>(map);
|
||||
}
|
||||
};
|
||||
|
||||
class WebUIMojoTest : public ContentBrowserTest,
|
||||
public testing::WithParamInterface<bool> {
|
||||
class WebUIMojoTest : public ContentBrowserTest {
|
||||
public:
|
||||
WebUIMojoTest() = default;
|
||||
|
||||
@ -350,9 +283,7 @@ class WebUIMojoTest : public ContentBrowserTest,
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string GetMojoWebUiHost() {
|
||||
return std::string(GetParam() ? kMojoWebUiTsHost : kMojoWebUiHost);
|
||||
}
|
||||
std::string GetMojoWebUiHost() { return kMojoWebUiTsHost; }
|
||||
|
||||
void SetUpOnMainThread() override {
|
||||
client_ = std::make_unique<TestWebUIContentBrowserClient>();
|
||||
@ -367,14 +298,6 @@ class WebUIMojoTest : public ContentBrowserTest,
|
||||
std::unique_ptr<TestWebUIContentBrowserClient> client_;
|
||||
};
|
||||
|
||||
// Test both JS and TS on Ash, since Ash widely uses both types of WebUI
|
||||
// bindings. Test TS only on other platforms.
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
INSTANTIATE_TEST_SUITE_P(All, WebUIMojoTest, testing::Bool());
|
||||
#else
|
||||
INSTANTIATE_TEST_SUITE_P(All, WebUIMojoTest, testing::Values(true));
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
// TODO(crbug.com/353502934): This test became flaky on Linux TSan builds since
|
||||
// 2024-07-16.
|
||||
@ -384,7 +307,7 @@ INSTANTIATE_TEST_SUITE_P(All, WebUIMojoTest, testing::Values(true));
|
||||
#endif
|
||||
// Loads a WebUI page that contains Mojo JS bindings and verifies a message
|
||||
// round-trip between the page and the browser.
|
||||
IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_EndToEndCommunication) {
|
||||
IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndCommunication) {
|
||||
// Load a dummy page in the initial RenderFrameHost. The initial
|
||||
// RenderFrameHost is created by the test harness prior to installing
|
||||
// TestWebUIContentBrowserClient in WebUIMojoTest::SetUpOnMainThread(). If we
|
||||
@ -438,7 +361,7 @@ IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_EndToEndCommunication) {
|
||||
#else
|
||||
#define MAYBE_NativeMojoAvailable NativeMojoAvailable
|
||||
#endif
|
||||
IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_NativeMojoAvailable) {
|
||||
IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_NativeMojoAvailable) {
|
||||
// Mojo bindings should be enabled.
|
||||
NavigateWithNewWebUI("web_ui_mojo_native.html");
|
||||
EXPECT_TRUE(RunBoolFunction("isNativeMojoAvailable()"));
|
||||
@ -466,7 +389,7 @@ IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_NativeMojoAvailable) {
|
||||
#else
|
||||
#define MAYBE_ChromeSendAvailable ChromeSendAvailable
|
||||
#endif
|
||||
IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_ChromeSendAvailable) {
|
||||
IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_ChromeSendAvailable) {
|
||||
// chrome.send is not available on mojo-only WebUIs.
|
||||
NavigateWithNewWebUI("web_ui_mojo_native.html");
|
||||
EXPECT_FALSE(RunBoolFunction("isChromeSendAvailable()"));
|
||||
@ -488,7 +411,7 @@ IN_PROC_BROWSER_TEST_P(WebUIMojoTest, MAYBE_ChromeSendAvailable) {
|
||||
EXPECT_FALSE(RunBoolFunction("isChromeSendAvailable()"));
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_P(WebUIMojoTest, ChromeSendAvailable_AfterCrash) {
|
||||
IN_PROC_BROWSER_TEST_F(WebUIMojoTest, ChromeSendAvailable_AfterCrash) {
|
||||
GURL test_url(GetWebUIURL(GetMojoWebUiHost() +
|
||||
"/web_ui_mojo_native.html?webui_bindings"));
|
||||
|
||||
|
@ -691,10 +691,6 @@ static_library("test_support") {
|
||||
}
|
||||
}
|
||||
|
||||
if (is_chromeos) {
|
||||
deps += [ ":web_ui_test_mojo_bindings" ]
|
||||
}
|
||||
|
||||
# HID support is not available without udev.
|
||||
is_linux_without_udev = (is_linux || is_chromeos) && !use_udev
|
||||
if (!is_linux_without_udev && !is_android) {
|
||||
@ -1120,25 +1116,6 @@ mojom("content_test_mojo_bindings") {
|
||||
]
|
||||
}
|
||||
|
||||
# Testing JS bindings only on Ash, since they are primarily used there and
|
||||
# because this test relies on the URL WebUI mojo bindings, which are
|
||||
# TypeScript only on other platforms.
|
||||
if (is_chromeos) {
|
||||
mojom("web_ui_test_mojo_bindings") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"data/web_ui_test.test-mojom",
|
||||
"data/web_ui_test_types.test-mojom",
|
||||
]
|
||||
public_deps = [ "//url/mojom:url_mojom_gurl" ]
|
||||
webui_module_path = "/content/test/data"
|
||||
|
||||
# Generate WebUI bindings in JavaScript instead of TypeScript. This is
|
||||
# necessary since this target is intentionally testing JS WebUI bindings.
|
||||
generate_webui_js_bindings = true
|
||||
}
|
||||
}
|
||||
|
||||
mojom("web_ui_managed_interface_tests_bindings") {
|
||||
testonly = true
|
||||
sources = [ "data/web_ui_managed_interface_test.test-mojom" ]
|
||||
@ -1146,22 +1123,6 @@ mojom("web_ui_managed_interface_tests_bindings") {
|
||||
webui_module_path = "/content/test/data"
|
||||
}
|
||||
|
||||
# Closure compilation is only used on Ash. See below for TypeScript targets
|
||||
# which are used across platforms.
|
||||
if (is_chromeos) {
|
||||
js_library("web_ui_mojo_test_js") {
|
||||
sources = [ "data/web_ui_mojo_test.js" ]
|
||||
deps = [ ":web_ui_test_mojo_bindings_webui_js" ]
|
||||
}
|
||||
|
||||
# NOTE: Building this target serves as a compile test for type-checking of
|
||||
# WebUI JS that consumes generated Mojom JS bindings.
|
||||
js_type_check("web_ui_mojo_test_js_type_check") {
|
||||
deps = [ ":web_ui_mojo_test_js" ]
|
||||
closure_flags = default_closure_args + mojom_js_args
|
||||
}
|
||||
}
|
||||
|
||||
# Test cross target mojo typemapping.
|
||||
mojom("web_ui_ts_test_other_mojo_bindings") {
|
||||
testonly = true
|
||||
@ -1984,10 +1945,6 @@ test("content_browsertests") {
|
||||
]
|
||||
}
|
||||
|
||||
if (is_chromeos) {
|
||||
deps += [ ":web_ui_test_mojo_bindings" ]
|
||||
}
|
||||
|
||||
if (enable_plugins) {
|
||||
sources += [ "../browser/plugin_service_impl_browsertest.cc" ]
|
||||
}
|
||||
@ -2141,10 +2098,7 @@ test("content_browsertests") {
|
||||
}
|
||||
|
||||
if (is_chromeos) {
|
||||
deps += [
|
||||
":web_ui_mojo_test_js_type_check",
|
||||
"//chromeos/ash/components/assistant:buildflags",
|
||||
]
|
||||
deps += [ "//chromeos/ash/components/assistant:buildflags" ]
|
||||
}
|
||||
|
||||
if (is_android) {
|
||||
@ -2410,10 +2364,6 @@ grit("web_ui_mojo_test_resources") {
|
||||
"web_ui_mojo_test_resources.pak",
|
||||
]
|
||||
deps = [ ":web_ui_mojo_test_build_ts" ]
|
||||
|
||||
if (is_chromeos) {
|
||||
deps += [ ":web_ui_test_mojo_bindings_js__generator" ]
|
||||
}
|
||||
}
|
||||
|
||||
static_library("run_all_unittests") {
|
||||
|
@ -8204,16 +8204,12 @@ data/web_ui_mojo_conformance_test.html
|
||||
data/web_ui_mojo_conformance_test.ts
|
||||
data/web_ui_mojo_native.html
|
||||
data/web_ui_mojo_native.js
|
||||
data/web_ui_mojo_test.html
|
||||
data/web_ui_mojo_test.js
|
||||
data/web_ui_mojo_ts_test.html
|
||||
data/web_ui_mojo_ts_test.ts
|
||||
data/web_ui_mojo_ts_test_converters.ts
|
||||
data/web_ui_mojo_ts_test_mapped_types.ts
|
||||
data/web_ui_mojo_ts_test_other_mapped_types.ts
|
||||
data/web_ui_shared_worker.js
|
||||
data/web_ui_test.test-mojom
|
||||
data/web_ui_test_types.test-mojom
|
||||
data/web_ui_ts_test.test-mojom
|
||||
data/web_ui_ts_test_other_types.test-mojom
|
||||
data/web_ui_ts_test_types.test-mojom
|
||||
|
@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="web_ui_mojo_test.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
x
|
||||
</body>
|
||||
</html>
|
@ -1,46 +0,0 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import {WebUIMojoTestCache} from './content/test/data/web_ui_test.test-mojom-webui.js';
|
||||
|
||||
/** @type {{send: function(*)}} */
|
||||
Window.prototype.domAutomationController;
|
||||
|
||||
const TEST_DATA = [
|
||||
{ url: 'https://google.com/', contents: 'i am in fact feeling lucky' },
|
||||
{ url: 'https://youtube.com/', contents: 'probably cat videos?' },
|
||||
{ url: 'https://example.com/', contents: 'internets wow' },
|
||||
];
|
||||
|
||||
async function doTest() {
|
||||
const cache = WebUIMojoTestCache.getRemote();
|
||||
for (const entry of TEST_DATA) {
|
||||
cache.put({ url: entry.url }, entry.contents);
|
||||
}
|
||||
|
||||
const {items} = await cache.getAll();
|
||||
if (items.length != TEST_DATA.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const entries = {};
|
||||
for (const item of items) {
|
||||
entries[item.url.url] = item.contents;
|
||||
}
|
||||
|
||||
for (const entry of TEST_DATA) {
|
||||
if (!(entry.url in entries)) {
|
||||
return false;
|
||||
}
|
||||
if (entries[entry.url] != entry.contents) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
window.runTest = async function() {
|
||||
return doTest();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
module content.mojom;
|
||||
|
||||
import "content/test/data/web_ui_test_types.test-mojom";
|
||||
import "url/mojom/url.mojom";
|
||||
|
||||
interface WebUIMojoTestCache {
|
||||
Put(url.mojom.Url url, string contents);
|
||||
GetAll() => (array<CacheItem> items);
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
module content.mojom;
|
||||
|
||||
import "url/mojom/url.mojom";
|
||||
|
||||
// This struct is imported by web_ui_test.test-mojom and is used to provide
|
||||
// test coverage of non-shared WebUI mojom JS modules importing other
|
||||
// non-shared WebUI mojom JS modules.
|
||||
struct CacheItem {
|
||||
url.mojom.Url url;
|
||||
string contents;
|
||||
};
|
||||
|
@ -17,18 +17,10 @@ This file specifies resources for content_browsertests.
|
||||
<include name="IDR_WEB_UI_MANAGED_INTERFACE_TEST_HTML" file="data/web_ui_managed_interface_test.html" type="BINDATA" resource_path="web_ui_managed_interface_test.html" />
|
||||
<include name="IDR_WEB_UI_MANAGED_INTERFACE_TEST_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_managed_interface_test.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_managed_interface_test.js" />
|
||||
<include name="IDR_WEB_UI_MANAGED_INTERFACE_TEST_TEST_MOJOM_WEBUI_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_managed_interface_test.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_managed_interface_test.test-mojom-webui.js" />
|
||||
<if expr="is_chromeos">
|
||||
<include name="IDR_WEB_UI_MOJO_HTML" file="data/web_ui_mojo_test.html" type="BINDATA" />
|
||||
<include name="IDR_WEB_UI_MOJO_JS" file="data/web_ui_mojo_test.js" type="BINDATA" resource_path="web_ui_mojo_test.js" />
|
||||
</if>
|
||||
<include name="IDR_WEB_UI_MOJO_TS_HTML" file="data/web_ui_mojo_ts_test.html" type="BINDATA" />
|
||||
<include name="IDR_WEB_UI_MOJO_TS_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_mojo_ts_test.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_mojo_ts_test.js" />
|
||||
<include name="IDR_WEB_UI_MOJO_NATIVE_HTML" file="data/web_ui_mojo_native.html" type="BINDATA" resource_path="web_ui_mojo_native.html" />
|
||||
<include name="IDR_WEB_UI_MOJO_NATIVE_JS" file="data/web_ui_mojo_native.js" type="BINDATA" resource_path="web_ui_mojo_native.js" />
|
||||
<if expr="is_chromeos">
|
||||
<include name="IDR_WEB_UI_TEST_MOJOM_JS" file="${root_gen_dir}/mojom-webui/content/test/data/web_ui_test.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="content/test/data/web_ui_test.test-mojom-webui.js" />
|
||||
<include name="IDR_WEB_UI_TEST_TYPES_MOJOM_JS" file="${root_gen_dir}/mojom-webui/content/test/data/web_ui_test_types.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="content/test/data/web_ui_test_types.test-mojom-webui.js" />
|
||||
</if>
|
||||
<include name="IDR_WEB_UI_TS_TEST_MOJOM_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_ts_test.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_ts_test.test-mojom-webui.js" />
|
||||
<include name="IDR_WEB_UI_TS_TEST_MOJOM_CONVERTER_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_ts_test.test-mojom-converters.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_ts_test.test-mojom-converters.js" />
|
||||
<include name="IDR_WEB_UI_TS_TEST_MOJOM_OTHER_TYPES_JS" file="${root_gen_dir}/content/test/data/tsc/web_ui_ts_test_other_types.test-mojom-webui.js" use_base_dir="false" type="BINDATA" resource_path="web_ui_ts_test_other_types.test-mojom-webui.js" />
|
||||
|
Reference in New Issue
Block a user