Commit 7a8b31a5 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Add openQuickViewBackgroundColorHtml test

Untrusted content (HTML here) is rendered in Quick View in a <webview>
element. Its parent <file-safe-media> sets the background color of the
rendered HTML and that color must be solid white. Test that.

Bug: 891150
Change-Id: I10975df3e862b4d8746c97adc43aaf18b248dd4b
Reviewed-on: https://chromium-review.googlesource.com/c/1258670Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596183}
parent 04679572
......@@ -380,6 +380,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("openQuickView").TabletMode(),
TestCase("openQuickViewScrollText"),
TestCase("openQuickViewScrollHtml"),
TestCase("openQuickViewBackgroundColorHtml"),
TestCase("openQuickViewDrive"),
TestCase("openQuickViewDrive").EnableDriveFs(),
TestCase("openQuickViewUsb"),
......
......@@ -430,3 +430,60 @@ testcase.openQuickViewScrollHtml = function() {
},
]);
};
/**
* Tests opening Quick View on an html document to verify that the background
* color of the <files-safe-media type="html"> that contains the <webview> is
* solid white.
*/
testcase.openQuickViewBackgroundColorHtml = function() {
const caller = getCaller();
let appId;
/**
* The <webview> resides in the <files-safe-media type="html"> shadow DOM,
* which is a child of the #quick-view shadow DOM. This test only needs to
* examine the <files-safe-media> element.
*/
const fileSafeMedia = ['#quick-view', 'files-safe-media[type="html"]'];
StepsRunner.run([
// Open Files app on Downloads containing ENTRIES.tallHtml.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.tallHtml], []);
},
// Open the file in Quick View.
function(results) {
appId = results.windowId;
const openSteps = openQuickViewSteps(appId, ENTRIES.tallHtml.nameText);
StepsRunner.run(openSteps).then(this.next);
},
// Get the <files-safe-media type='html'> backgroundColor style.
function() {
function getFileSafeMediaBackgroundColor(elements) {
let haveElements = Array.isArray(elements) && elements.length === 1;
if (haveElements)
haveElements = elements[0].styles.display.includes('block');
if (!haveElements || !elements[0].styles.backgroundColor)
return pending(caller, 'Waiting for <file-safe-media> element.');
return elements[0].styles.backgroundColor;
}
repeatUntil(function() {
const styles = ['display', 'backgroundColor'];
return remoteCall
.callRemoteTestUtil(
'deepQueryAllElements', appId, [fileSafeMedia, styles])
.then(getFileSafeMediaBackgroundColor);
}).then(this.next);
},
// Check: the <files-safe-media> backgroundColor should be solid white.
function(backgroundColor) {
chrome.test.assertEq('rgb(255, 255, 255)', backgroundColor);
this.next();
},
function(results) {
checkIfNoErrorsOccured(this.next);
},
]);
};
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