Bug 1214878 - add tests. r=roc
authorJim Mathies <jmathies@mozilla.com>
Mon, 19 Oct 2015 10:38:42 -0500
changeset 303554 eddce960bab66cda1f940b39cbb1d006863bcb17
parent 303553 59588063362c741672381032638d1f38a82668c2
child 303555 89d1402a45f44d3286e88ac3b326e93f2cbba972
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1214878
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1214878 - add tests. r=roc
dom/plugins/test/mochitest/browser.ini
dom/plugins/test/mochitest/browser_pluginscroll.js
dom/plugins/test/mochitest/plugin_no_scroll_div.html
dom/plugins/test/mochitest/plugin_subframe_test.html
--- a/dom/plugins/test/mochitest/browser.ini
+++ b/dom/plugins/test/mochitest/browser.ini
@@ -1,12 +1,14 @@
 [DEFAULT]
 support-files =
   head.js
   plugin_test.html
+  plugin_subframe_test.html
+  plugin_no_scroll_div.html
 
 [browser_bug1163570.js]
 skip-if = (!e10s || os != "win")
 [browser_bug1196539.js]
 skip-if = (!e10s || os != "win")
 [browser_tabswitchbetweenplugins.js]
 skip-if = (!e10s || os != "win")
 [browser_pluginscroll.js]
--- a/dom/plugins/test/mochitest/browser_pluginscroll.js
+++ b/dom/plugins/test/mochitest/browser_pluginscroll.js
@@ -35,17 +35,17 @@ add_task(function*() {
                ["general.smoothScroll.other.durationMinMS", 1999],
                ["general.smoothScroll.mouseWheel.durationMaxMS", 2000],
                ["general.smoothScroll.mouseWheel.durationMinMS", 1999],
              ]}, resolve);
   });
 });
 
 /*
- * 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* () {
   let result;
 
   if (!apzEnabled) {
     ok(true, "nothing to test, need apz");
     return;
@@ -100,20 +100,84 @@ add_task(function* () {
     return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
   });
   is(result, true, "plugin is visible");
 
   gBrowser.removeTab(pluginTab);
 });
 
 /*
- * 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* () {
   let result;
 
   if (!pluginHideEnabled) {
     ok(true, "nothing to test, need gfx.e10s.hide-plugins-for-scroll");
     return;
@@ -166,8 +230,73 @@ add_task(function* () {
     let doc = content.document;
     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 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);
+});
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/mochitest/plugin_no_scroll_div.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/mochitest/plugin_subframe_test.html
@@ -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>