Bug 1306536 - Test; r=mconley draft
authorChun-Min Chang <chun.m.chang@gmail.com>
Wed, 05 Oct 2016 10:40:23 +0800
changeset 420995 8e2a0a5ec1ac98bb4959c451055f1f2a2c722b6e
parent 420427 b3a9774ce78ac01f443068cd2375c59643739855
child 532940 0c15e1db241d97a71b9cceb04f46bc7019a7d4f7
push id31344
push userbmo:cchang@mozilla.com
push dateWed, 05 Oct 2016 02:40:56 +0000
reviewersmconley
bugs1306536
milestone52.0a1
Bug 1306536 - Test; r=mconley MozReview-Commit-ID: CqPEbcfFMqF
browser/modules/test/browser_PermissionUI.js
--- a/browser/modules/test/browser_PermissionUI.js
+++ b/browser/modules/test/browser_PermissionUI.js
@@ -153,16 +153,65 @@ add_task(function* test_permission_promp
     let removePromise =
       BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden");
     notification.remove();
     yield removePromise;
   });
 });
 
 /**
+ * Tests that if the PermissionPrompt sets displayURI to false in popupOptions,
+ * then there is no URI shown on the popupnotification.
+ */
+add_task(function* test_permission_prompt_for_popupOptions() {
+  yield BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: "http://example.com/",
+  }, function*(browser) {
+    const kTestNotificationID = "test-notification";
+    const kTestMessage = "Test message";
+    let mainAction = {
+      label: "Main",
+      accessKey: "M",
+    };
+    let secondaryAction = {
+      label: "Secondary",
+      accessKey: "S",
+    };
+
+    let mockRequest = makeMockPermissionRequest(browser);
+    let TestPrompt = {
+      __proto__: PermissionUI.PermissionPromptForRequestPrototype,
+      request: mockRequest,
+      notificationID: kTestNotificationID,
+      message: kTestMessage,
+      promptActions: [mainAction, secondaryAction],
+      popupOptions: {
+        displayURI: false,
+      },
+    };
+
+    let shownPromise =
+      BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
+    TestPrompt.prompt();
+    yield shownPromise;
+    let notification =
+      PopupNotifications.getNotification(kTestNotificationID, browser);
+
+    Assert.ok(!notification.options.displayURI,
+              "Should not show the URI of the requesting page");
+
+    let removePromise =
+      BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden");
+    notification.remove();
+    yield removePromise;
+  });
+});
+
+/**
  * Tests that if the PermissionPrompt has the permissionKey
  * set that permissions can be set properly by the user. Also
  * ensures that callbacks for promptActions are properly fired.
  */
 add_task(function* test_with_permission_key() {
   yield BrowserTestUtils.withNewTab({
     gBrowser,
     url: "http://example.com",