Commit f0db84bd authored by dpapad's avatar dpapad Committed by Commit Bot

MojoWebUIBrowserTest: Allow compressing of test resources.

Previously the code assumed, via the usage of
l10n_util::GetStringUTF16, that the underlying resources at
chrome/test/data/webui_test_resources.grd are not compressed.

Moreover, using l10n_util::GetStringUTF16() is not designed for fetching
a file's content and was somewhat misused here.

This is one of many CLs, in preparation of compressing all HTML, JS,
CSS, SVG files by default (meaning without requiring compress="gzip"
to be specified).

Bug: 1068407
Change-Id: I77fe0f9966f6e277288838c42260433c34bd403c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146090
Auto-Submit: dpapad <dpapad@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#758538}
parent 3d22ab40
......@@ -23,7 +23,6 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/service_manager/public/cpp/binder_map.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace {
......@@ -129,12 +128,16 @@ void MojoWebUIBrowserTest::BrowsePreload(const GURL& browse_to) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
if (use_mojo_lite_bindings_) {
std::string test_mojo_lite_js =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_WEB_UI_TEST_MOJO_LITE_JS);
web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
l10n_util::GetStringUTF16(IDR_WEB_UI_TEST_MOJO_LITE_JS),
base::NullCallback());
base::UTF8ToUTF16(test_mojo_lite_js), base::NullCallback());
} else {
std::string test_mojo_js =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_WEB_UI_TEST_MOJO_JS);
web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
l10n_util::GetStringUTF16(IDR_WEB_UI_TEST_MOJO_JS),
base::NullCallback());
base::UTF8ToUTF16(test_mojo_js), base::NullCallback());
}
}
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