Bug 1214878 - add tests. r=roc

This commit is contained in:
Jim Mathies 2015-10-19 10:38:42 -05:00
parent a430dc90dc
commit 4e7aea34e7
4 changed files with 156 additions and 5 deletions

View File

@ -2,6 +2,8 @@
support-files =
head.js
plugin_test.html
plugin_subframe_test.html
plugin_no_scroll_div.html
[browser_bug1163570.js]
skip-if = (!e10s || os != "win")

View File

@ -40,7 +40,7 @@ add_task(function*() {
});
/*
* test plugin visibility when scrolling with scroll wheel and apz.
* test plugin visibility when scrolling with scroll wheel and apz in a top level document.
*/
add_task(function* () {
@ -105,10 +105,74 @@ add_task(function* () {
});
/*
* test visibility when scrolling with keyboard shortcuts. This circumvents apz
* and relies on dom scroll, which is what we want to target for this test. Note
* this test should only run with e10s since we do not hide plugin windows when
* scrolling in single process mode.
* test plugin visibility when scrolling with scroll wheel and apz in a sub document.
*/
add_task(function* () {
let result;
if (!apzEnabled) {
ok(true, "nothing to test, need apz");
return;
}
if (!pluginHideEnabled) {
ok(true, "nothing to test, need gfx.e10s.hide-plugins-for-scroll");
return;
}
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
let testTab = gBrowser.selectedTab;
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_subframe_test.html");
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return !!plugin;
});
is(result, true, "plugin is loaded");
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, true, "plugin is visible");
let nativeId = nativeVerticalWheelEventMsg();
let utils = SpecialPowers.getDOMWindowUtils(window);
let screenCoords = coordinatesRelativeToWindow(10, 10,
gBrowser.selectedBrowser);
utils.sendNativeMouseScrollEvent(screenCoords.x, screenCoords.y,
nativeId, 0, -50, 0, 0, 0,
gBrowser.selectedBrowser);
yield waitScrollStart(gBrowser.selectedBrowser);
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, false, "plugin is hidden");
yield waitScrollFinish(gBrowser.selectedBrowser);
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, true, "plugin is visible");
gBrowser.removeTab(pluginTab);
});
/*
* test visibility when scrolling with keyboard shortcuts for a top level document.
* This circumvents apz and relies on dom scroll, which is what we want to target
* for this test.
*/
add_task(function* () {
@ -171,3 +235,68 @@ add_task(function* () {
gBrowser.removeTab(pluginTab);
});
/*
* test visibility when scrolling with keyboard shortcuts for a sub document.
*/
add_task(function* () {
let result;
if (!pluginHideEnabled) {
ok(true, "nothing to test, need gfx.e10s.hide-plugins-for-scroll");
return;
}
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
let testTab = gBrowser.selectedTab;
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_subframe_test.html");
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return !!plugin;
});
is(result, true, "plugin is loaded");
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, true, "plugin is visible");
EventUtils.synthesizeKey("VK_END", {});
yield waitScrollStart(gBrowser.selectedBrowser);
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, false, "plugin is hidden");
yield waitScrollFinish(gBrowser.selectedBrowser);
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, false, "plugin is hidden");
EventUtils.synthesizeKey("VK_HOME", {});
yield waitScrollFinish(gBrowser.selectedBrowser);
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
let doc = content.document.getElementById("subframe").contentDocument;
let plugin = doc.getElementById("testplugin");
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
});
is(result, true, "plugin is visible");
gBrowser.removeTab(pluginTab);
});

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<embed id="testplugin" type="application/x-test" drawmode="solid" color="ff00ff00" wmode="window"
style="position:absolute; top:5px; left:5px; width:500px; height:250px">
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe id="subframe" style="width:510px; height:260px;" src="plugin_no_scroll_div.html"></iframe>
<div style="display:block; height:3000px;"></div>
</body>
</html>