Commit a87fd3ae authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Cleanup fullscreen tests by not listening to events after tests end

This patch cleans up flakiness caused by video-overlay-scroll.html which
had a fullscreenchange event handler that fired twice, but was only
intended to fire once in the test. The test used waitForEventAndEnd
which continued calling the event handler after the test ended. This
patch updates this function to waitForEventOnceAndEnd which makes it
clear that the event handler will be removed after firing once.

The root-cause of this flakiness is being fixed in
https://crrev.com/c/2275348 and this patch is just followup cleanup.

Bug: 1048597
Change-Id: I4b7473879085e5a7f91875f4daa53a2891c9274e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2275350Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784142}
parent 5c3cc877
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
function init() { function init() {
var iframe = document.getElementById('block1'); var iframe = document.getElementById('block1');
var element = iframe.contentDocument.documentElement; var element = iframe.contentDocument.documentElement;
waitForEventAndEnd(element, 'webkitfullscreenchange'); waitForEventOnceAndEnd(element, 'webkitfullscreenchange');
runWithKeyDown(goFullScreen); runWithKeyDown(goFullScreen);
} }
......
...@@ -15,7 +15,7 @@ iframe { ...@@ -15,7 +15,7 @@ iframe {
<script> <script>
iframe = document.querySelector('iframe'); iframe = document.querySelector('iframe');
waitForEventAndEnd(document, 'webkitfullscreenchange', function() waitForEventOnceAndEnd(document, 'webkitfullscreenchange', function()
{ {
computedStyle = getComputedStyle(iframe); computedStyle = getComputedStyle(iframe);
testExpected('computedStyle.minWidth', '0px'); testExpected('computedStyle.minWidth', '0px');
......
...@@ -15,7 +15,7 @@ video { ...@@ -15,7 +15,7 @@ video {
<script> <script>
video = document.querySelector('video'); video = document.querySelector('video');
waitForEventAndEnd(document, 'webkitfullscreenchange', function() waitForEventOnceAndEnd(document, 'webkitfullscreenchange', function()
{ {
computedStyle = getComputedStyle(video); computedStyle = getComputedStyle(video);
testExpected('computedStyle.minWidth', '0px'); testExpected('computedStyle.minWidth', '0px');
......
...@@ -11,7 +11,7 @@ in those platforms where fullscreen is not supported. ...@@ -11,7 +11,7 @@ in those platforms where fullscreen is not supported.
logResult(false, 'Entered fullscreen.'); logResult(false, 'Entered fullscreen.');
endTest(); endTest();
}); });
waitForEventAndEnd(document, 'webkitfullscreenerror'); waitForEventOnceAndEnd(document, 'webkitfullscreenerror');
runWithKeyDown(function(){document.getElementById('video').webkitRequestFullScreen()}); runWithKeyDown(function(){document.getElementById('video').webkitRequestFullScreen()});
} }
</script> </script>
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
}); });
if (window.testRunner) if (window.testRunner)
testRunner.setPopupBlockingEnabled(true); testRunner.setPopupBlockingEnabled(true);
waitForEventAndEnd(document, 'webkitfullscreenerror'); waitForEventOnceAndEnd(document, 'webkitfullscreenerror');
document.documentElement.webkitRequestFullScreen(); document.documentElement.webkitRequestFullScreen();
</script> </script>
...@@ -4,11 +4,11 @@ Emit an error event when a request to enter full-screen is rejected.</p> ...@@ -4,11 +4,11 @@ Emit an error event when a request to enter full-screen is rejected.</p>
<script src="full-screen-test.js"></script> <script src="full-screen-test.js"></script>
<script> <script>
function runTest() { function runTest() {
waitForEventAndEnd(document, 'webkitfullscreenchange', function() { waitForEventOnceAndEnd(document, 'webkitfullscreenchange', function() {
consoleWrite("FAIL - entered full screen!"); consoleWrite("FAIL - entered full screen!");
}); });
waitForEventAndEnd(document, 'webkitfullscreenerror', function() { waitForEventOnceAndEnd(document, 'webkitfullscreenerror', function() {
consoleWrite("SUCCEED - did not enter full screen!"); consoleWrite("SUCCEED - did not enter full screen!");
}); });
......
...@@ -87,9 +87,9 @@ function reportExpected(success, testFuncString, comparison, expected, observed) ...@@ -87,9 +87,9 @@ function reportExpected(success, testFuncString, comparison, expected, observed)
logResult(success, msg); logResult(success, msg);
} }
function waitForEventAndEnd(element, eventName, funcString) function waitForEventOnceAndEnd(element, eventName, funcString)
{ {
waitForEvent(element, eventName, funcString, true) waitForEvent(element, eventName, funcString, true, true)
} }
function waitForEventOnce(element, eventName, func, endit) function waitForEventOnce(element, eventName, func, endit)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
var spanEnteredFullScreen = function() { var spanEnteredFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", span); testExpected("document.webkitCurrentFullScreenElement", span);
waitForEventAndEnd(document, "webkitfullscreenchange"); waitForEventOnceAndEnd(document, "webkitfullscreenchange");
runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()}); runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()});
}; };
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
var runPixelTests = true; var runPixelTests = true;
function init() { function init() {
waitForEventAndEnd(document, 'webkitfullscreenchange'); waitForEventOnceAndEnd(document, 'webkitfullscreenchange');
runWithKeyDown(goFullScreen); runWithKeyDown(goFullScreen);
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
eventSender.mouseDown(); eventSender.mouseDown();
waitForEvent(timeline, 'mouseup'); waitForEvent(timeline, 'mouseup');
waitForEventAndEnd(video, 'seeked'); waitForEventOnceAndEnd(video, 'seeked');
eventSender.mouseUp(); eventSender.mouseUp();
} }
else else
......
...@@ -8,7 +8,7 @@ This test verifies videos in fullscreen mode are not affected by CSS top/left pr ...@@ -8,7 +8,7 @@ This test verifies videos in fullscreen mode are not affected by CSS top/left pr
var clientRect; var clientRect;
var video = document.getElementById('video'); var video = document.getElementById('video');
waitForEventAndEnd(document, 'webkitfullscreenchange', function(){ waitForEventOnceAndEnd(document, 'webkitfullscreenchange', function(){
clientRect = video.getBoundingClientRect(); clientRect = video.getBoundingClientRect();
testExpected('clientRect.left', 0) testExpected('clientRect.left', 0)
testExpected('clientRect.top', 0) testExpected('clientRect.top', 0)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
logResult(false, "Element.prototype.webkitRequestFullScreen == undefined"); logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
endTest(); endTest();
} else { } else {
waitForEventAndEnd(document, 'webkitfullscreenchange'); waitForEventOnceAndEnd(document, 'webkitfullscreenchange');
runWithKeyDown(function(){video.webkitRequestFullScreen()}); runWithKeyDown(function(){video.webkitRequestFullScreen()});
} }
</script> </script>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
logResult(false, "Element.prototype.webkitRequestFullScreen == undefined"); logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
endTest(); endTest();
} else { } else {
waitForEventAndEnd(document, 'webkitfullscreenchange'); waitForEventOnceAndEnd(document, 'webkitfullscreenchange');
runWithKeyDown(function(){video.webkitRequestFullScreen()}); runWithKeyDown(function(){video.webkitRequestFullScreen()});
} }
</script> </script>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
testRunner.dumpAsText(); testRunner.dumpAsText();
window.scrollTo(0, 1000); window.scrollTo(0, 1000);
waitForEventAndEnd(document, 'fullscreenchange', function(){ waitForEventOnceAndEnd(document, 'fullscreenchange', function(){
testRunner.setCustomTextOutput(internals.layerTreeAsText(document)); testRunner.setCustomTextOutput(internals.layerTreeAsText(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