Commit 67e12947 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Make openQuickViewScrollText robust

The QuickView text <webview> provides no signal that it is loaded, but
it does have a src attribute. That can used as a proxy for loaded, and
help make a test that is robust (to load / script timing) on the bots.

 - make the text <webview> selector precise (.text-content class)
 - change the text scroll test to check the webview src attribute
   is non-empty before proceeding.
 - change to use scrollBy, and send incremental scrolls until the
   the scroll limit is reached [1].

[1] if the bot misses or drops a JS scrollBy request, no problem: just
ask for it again.

Bug: 891150
Change-Id: I0bb49c2b08b3535172819a3c1088fca5ba6fda94
Reviewed-on: https://chromium-review.googlesource.com/1256469Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595747}
parent 2f9fe770
......@@ -263,13 +263,27 @@ testcase.openQuickViewScrollText = function() {
const caller = getCaller();
let appId;
function checkQuickViewTextScrollY(scrollY) {
if (Number(scrollY.toString()) < 100)
return pending(caller, 'Waiting for Quick View to scroll.');
return;
/**
* 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'];
function scrollQuickViewTextBy(y) {
const doScrollBy = `window.scrollBy(0,${y})`;
return remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [webView, doScrollBy]);
}
const textView = ['#quick-view', 'webview'];
function checkQuickViewTextScrollY(scrollY) {
if (!scrollY || Number(scrollY.toString()) <= 200) {
console.log('checkQuickViewTextScrollY: scrollY '.concat(scrollY));
return scrollQuickViewTextBy(100).then(() => {
return pending(caller, 'Waiting for Quick View to scroll.');
});
}
}
StepsRunner.run([
// Open Files app on Downloads containing ENTRIES.tallText.
......@@ -283,34 +297,43 @@ testcase.openQuickViewScrollText = function() {
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 Quick View <webview> scrollY.
function() {
const getScrollY = 'window.scrollY';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [textView, getScrollY])
'deepExecuteScriptInWebView', appId, [webView, getScrollY])
.then(this.next);
},
// Check: the initial <webview> scrollY should be 0.
function(result) {
chrome.test.assertEq('0', result.toString());
function(scrollY) {
chrome.test.assertEq('0', scrollY.toString());
this.next();
},
// Scroll the Quick View <webview> in the Y direction (down).
function() {
const doScrollTo = 'window.scrollTo(0,1000)';
remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [textView, doScrollTo])
.then(this.next);
},
// Check: the <webview> should be scrolled in the Y direction.
// Scroll the <webview> and verify that it scrolled.
function() {
repeatUntil(function() {
const getScrollY = 'window.scrollY';
return remoteCall
.callRemoteTestUtil(
'deepExecuteScriptInWebView', appId, [textView, getScrollY])
'deepExecuteScriptInWebView', appId, [webView, getScrollY])
.then(checkQuickViewTextScrollY);
}).then(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