Bug 1278763 - Part 2: Add tests for permission prompts, r=jryans
authorBenoit Chabod <bchabod@mozilla.com>
Wed, 10 Aug 2016 17:11:44 -0700
changeset 399638 c4a79e57209adab8f38ca9ea9da8317bf748235a
parent 399637 356bb4c55f4dde7fae5f814208e1344ed74f20bd
child 399639 481b43b3340f0f960063264eee946314d4357a79
push id25905
push userdtownsend@mozilla.com
push dateThu, 11 Aug 2016 17:57:58 +0000
reviewersjryans
bugs1278763
milestone51.0a1
Bug 1278763 - Part 2: Add tests for permission prompts, r=jryans
devtools/client/responsive.html/test/browser/browser.ini
devtools/client/responsive.html/test/browser/browser_permission_doorhanger.js
devtools/client/responsive.html/test/browser/geolocation.html
--- a/devtools/client/responsive.html/test/browser/browser.ini
+++ b/devtools/client/responsive.html/test/browser/browser.ini
@@ -1,16 +1,17 @@
 [DEFAULT]
 tags = devtools
 subsuite = devtools
 # !e10s: RDM only works for remote tabs
 skip-if = !e10s
 support-files =
   devices.json
   doc_page_state.html
+  geolocation.html
   head.js
   !/devtools/client/commandline/test/helpers.js
   !/devtools/client/framework/test/shared-head.js
   !/devtools/client/framework/test/shared-redux-head.js
   !/devtools/client/inspector/test/shared-head.js
   !/devtools/client/shared/test/test-actor.js
   !/devtools/client/shared/test/test-actor-registry.js
 
@@ -20,16 +21,17 @@ support-files =
 [browser_device_width.js]
 [browser_exit_button.js]
 [browser_frame_script_active.js]
 [browser_menu_item_01.js]
 [browser_menu_item_02.js]
 [browser_mouse_resize.js]
 [browser_navigation.js]
 [browser_page_state.js]
+[browser_permission_doorhanger.js]
 [browser_resize_cmd.js]
 skip-if = true # GCLI target confused after swap, will fix in bug 1240912
 [browser_screenshot_button.js]
 [browser_shutdown_close_sync.js]
 [browser_toolbox_computed_view.js]
 [browser_toolbox_rule_view.js]
 [browser_touch_simulation.js]
 [browser_viewport_basics.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/responsive.html/test/browser/browser_permission_doorhanger.js
@@ -0,0 +1,52 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that permission popups asking for user approval still appear in RDM
+const DUMMY_URL = "http://example.com/";
+const TEST_URL = `${URL_ROOT}geolocation.html`;
+
+function waitForGeolocationPrompt(win, browser) {
+  return new Promise(resolve => {
+    win.PopupNotifications.panel.addEventListener("popupshown", function popupShown() {
+      let notification = win.PopupNotifications.getNotification("geolocation", browser);
+      if (notification) {
+        win.PopupNotifications.panel.removeEventListener("popupshown", popupShown);
+        resolve();
+      }
+    });
+  });
+}
+
+add_task(function* () {
+  let tab = yield addTab(DUMMY_URL);
+  let browser = tab.linkedBrowser;
+  let win = browser.ownerGlobal;
+
+  let waitPromptPromise = waitForGeolocationPrompt(win, browser);
+
+  // Checks if a geolocation permission doorhanger appears when openning a page
+  // requesting geolocation
+  yield load(browser, TEST_URL);
+  yield waitPromptPromise;
+
+  ok(true, "Permission doorhanger appeared without RDM enabled");
+
+  // Lets switch back to the dummy website and enable RDM
+  yield load(browser, DUMMY_URL);
+  let { ui } = yield openRDM(tab);
+  let newBrowser = ui.getViewportBrowser();
+
+  waitPromptPromise = waitForGeolocationPrompt(win, newBrowser);
+
+  // Checks if the doorhanger appeared again when reloading the geolocation
+  // page inside RDM
+  yield load(browser, TEST_URL);
+  yield waitPromptPromise;
+
+  ok(true, "Permission doorhanger appeared inside RDM");
+
+  yield closeRDM(tab);
+  yield removeTab(tab);
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/responsive.html/test/browser/geolocation.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Geolocation permission test</title>
+  </head>
+  <body>
+    <script type="text/javascript">
+      "use strict";
+      navigator.geolocation.getCurrentPosition(function (pos) {});
+    </script>
+  </body>
+</html>
\ No newline at end of file