Commit 025fa15c authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Force the QuickView background white when displaying text documents

In issue 883117 an externally injected stylesheet changed scroll style
of QuickView text documents: scroll bars went missing.

Investigating more, I find the background color of QuickView <webview>
content is also not set, so it is currently possible for an externally
injected stlyesheet to override the background color of text documents
in QuickView by accident.

Prevent such accidents - set the <webview> content background color to
white and add a test to verify the background color.

Bug: 891150
Change-Id: Ic7881ae45b2f36ba94ed245bae3d5944cda0eb2e
Reviewed-on: https://chromium-review.googlesource.com/c/1260784Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596517}
parent d3447bbe
...@@ -388,6 +388,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -388,6 +388,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("openQuickView").TabletMode(), TestCase("openQuickView").TabletMode(),
TestCase("openQuickViewScrollText"), TestCase("openQuickViewScrollText"),
TestCase("openQuickViewScrollHtml"), TestCase("openQuickViewScrollHtml"),
TestCase("openQuickViewBackgroundColorText"),
TestCase("openQuickViewBackgroundColorHtml"), TestCase("openQuickViewBackgroundColorHtml"),
TestCase("openQuickViewDrive"), TestCase("openQuickViewDrive"),
TestCase("openQuickViewDrive").EnableDriveFs(), TestCase("openQuickViewDrive").EnableDriveFs(),
......
...@@ -19,6 +19,7 @@ body { ...@@ -19,6 +19,7 @@ body {
} }
html { html {
background: white;
overflow: auto; overflow: auto;
} }
......
...@@ -343,6 +343,69 @@ testcase.openQuickViewScrollText = function() { ...@@ -343,6 +343,69 @@ testcase.openQuickViewScrollText = function() {
]); ]);
}; };
/**
* Tests opening Quick View on a text document to verify that the background
* color of the <webview> root (html) element is solid white.
*/
testcase.openQuickViewBackgroundColorText = function() {
const caller = getCaller();
let appId;
/**
* The text <webview> resides in the #quick-view shadow DOM, as a child of
* the #dialog element.
*/
const webView = ['#quick-view', '#dialog[open] webview.text-content'];
StepsRunner.run([
// Open Files app on Downloads containing ENTRIES.tallText.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallText], []);
},
// Open the file in Quick View.
function(results) {
appId = results.windowId;
const openSteps = openQuickViewSteps(appId, ENTRIES.tallText.nameText);
StepsRunner.run(openSteps).then(this.next);
},
// Wait for the Quick View <webview> to load and display its content.
function() {
function checkWebViewTextLoaded(elements) {
let haveElements = Array.isArray(elements) && elements.length === 1;
if (haveElements)
haveElements = elements[0].styles.display.includes('block');
if (!haveElements || !elements[0].attributes.src)
return pending(caller, 'Waiting for <webview> to load.');
return;
}
repeatUntil(function() {
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId, [webView, ['display']])
.then(checkWebViewTextLoaded);
}).then(this.next);
},
// Get the <webview> root (html) element backgroundColor style.
function() {
const getBackgroundStyle =
'window.getComputedStyle(document.documentElement).backgroundColor';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, getBackgroundStyle])
.then(this.next);
},
// Check: the <webview> root backgroundColor should be solid white.
function(backgroundColor) {
chrome.test.assertEq('rgb(255, 255, 255)', backgroundColor[0]);
this.next();
},
function(results) {
checkIfNoErrorsOccured(this.next);
},
]);
};
/** /**
* Tests opening Quick View and scrolling its <webview> which contains a tall * Tests opening Quick View and scrolling its <webview> which contains a tall
* html document. * html document.
......
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