Bug 1338172 part D - Fix tests that expect windowed mode on Linux, r=jimm

MozReview-Commit-ID: 8zAZ3K9LxlW

--HG--
extra : rebase_source : be1cafc78a1a7fe7f88181211ad5fa678260cd80
extra : source : 1c92fbfca20a1fc85df7aa617962a80b49869f79
This commit is contained in:
Benjamin Smedberg 2017-02-09 10:16:18 -05:00
Родитель 97d5872250
Коммит 183387de41
2 изменённых файлов: 27 добавлений и 25 удалений

Просмотреть файл

@ -4,12 +4,13 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=545812
Test plugins with DOM full-screen API:
* Presence of plugins has no effect on request for full-screen on MacOS.
* Request for full-screen is denied when windowed plugin in current doc is present.
* Request for full-screen is denied when windowed plugin in subdocument is present.
* Request for full-screen is not denied when the only plugin present is windowless.
* Adding an existing (out-of-doc) windowed plugin to a full-screen document causes document to exit full-screen.
* Create windowed plugin and adding it to full-screen document caused exit from full-screen.
* On non-Windows, plugins can only be windowless, so the presence of plugins
should have no effect on request for full-screen.
-->
<head>
@ -65,7 +66,7 @@ function removeElement(e) {
e.remove();
}
const isMacOs = navigator.appVersion.indexOf("Macintosh") != -1;
const supportsWindowedMode = navigator.appVersion.indexOf("Windows") != -1;
var windowedPlugin = null;
@ -83,37 +84,38 @@ function startTest() {
ok(!document.fullscreenElement, "Should not be in full-screen mode initially");
document.body.requestFullscreen();
// Focus the windowed plugin. On MacOS we should still enter full-screen mode,
// on windows the pending request for full-screen should be denied.
// Focus the windowed plugin. On non-Windows we should still enter
// full-screen mode, on Windows the pending request for full-screen should
// be denied.
e("windowed-plugin").focus();
if (isMacOs) {
// Running on MacOS, all plugins are effectively windowless, request for full-screen should be granted.
// Continue test in the (mac-specific) "fullscreenchange" handler.
addFullscreenChangeContinuation("enter", macFullScreenChange1);
if (!supportsWindowedMode) {
// If all plugins are effectively windowless, request for full-screen should be granted.
// Continue test in the "fullscreenchange" handler.
addFullscreenChangeContinuation("enter", windowlessFullScreenChange1);
} else {
// Non-MacOS, request should be denied, carry on the test after receiving error event.
addFullscreenErrorContinuation(nonMacTest);
// On Windows, request should be denied, carry on the test after receiving error event.
addFullscreenErrorContinuation(windowsTest);
}
}
function nonMacTest() {
function windowsTest() {
ok(!document.fullscreenElement, "Request for full-screen with focused windowed plugin should be denied.");
// Focus a regular html element, and re-request full-screen, request should be granted.
e("windowless-plugin").focus();
addFullscreenChangeContinuation("enter", nonMacTest2);
addFullscreenChangeContinuation("enter", windowsTest2);
document.body.requestFullscreen();
}
function nonMacTest2() {
function windowsTest2() {
ok(document.fullscreenElement, "Request for full-screen with non-plugin focused should be granted.");
// Focus a windowed plugin, full-screen should be revoked.
addFullscreenChangeContinuation("exit", nonMacTest3);
addFullscreenChangeContinuation("exit", windowsTest3);
e("windowed-plugin").focus();
}
function nonMacTest3() {
function windowsTest3() {
ok(!document.fullscreenElement, "Full-screen should have been revoked when windowed-plugin was focused.");
// Remove windowed plugins before closing the window
// to work around bug 1237853.
@ -131,25 +133,25 @@ function createWindowedPlugin() {
return p;
}
function macFullScreenChange1(event) {
ok(document.fullscreenElement, "Requests for full-screen with focused windowed plugins should be granted on MacOS");
function windowlessFullScreenChange1(event) {
ok(document.fullscreenElement, "Requests for full-screen with focused windowed plugins should be granted on non-Windows");
// Create a new windowed plugin, and add that to the document. Should *not* exit full-screen mode on MacOS.
// Create a new windowed plugin, and add that to the document. Should *not* exit full-screen mode on MacOS/Linux.
windowedPlugin = createWindowedPlugin();
document.body.appendChild(windowedPlugin);
// Focus windowed plugin. Should not exit full-screen mode on MacOS.
// Focus windowed plugin. Should not exit full-screen mode on MacOS/Linux.
windowedPlugin.focus();
setTimeout(
function() {
ok(document.fullscreenElement, "Adding & focusing a windowed plugin to document should not cause full-screen to exit on MacOS.");
addFullscreenChangeContinuation("exit", macFullScreenChange2);
ok(document.fullscreenElement, "Adding & focusing a windowed plugin to document should not cause full-screen to exit on MacOS/Linux.");
addFullscreenChangeContinuation("exit", windowlessFullScreenChange2);
document.exitFullscreen();
}, 0);
}
function macFullScreenChange2(event) {
function windowlessFullScreenChange2(event) {
ok(!document.fullscreenElement, "Should have left full-screen mode after calling document.exitFullscreen().");
opener.nextTest();
}

Просмотреть файл

@ -21,14 +21,14 @@ SimpleTest.waitForExplicitFinish();
function runTests() {
var p1 = document.getElementById("plugin1");
is(p1.hasWidget(), false, "Plugin should be windowless by default");
var p2 = document.getElementById("plugin2");
if (navigator.platform.indexOf("Mac") >= 0) {
is(p2.hasWidget(), false, "Mac does not support windowed plugins");
} else if (navigator.platform.indexOf("Win") >= 0) {
is(p2.hasWidget(), true, "Windows supports windowed plugins");
} else if (navigator.platform.indexOf("Linux") >= 0) {
is(p2.hasWidget(), true, "Linux supports windowed plugins");
is(p2.hasWidget(), false, "Linux does not support windowed plugins");
}
SimpleTest.finish();