Bug 1517368 - Expose PopupBlocker status via ChromeUtils - tests, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 04 Jan 2019 16:16:59 +0100
changeset 509695 e6f6dc496d61e33853d5aa71713f7b2a7416f96f
parent 509694 9dfb6ebdf897d8bab0ddefb460ece64786cbe8f6
child 509696 7ffc28df24ee8e6cde5f5dacd63fe27aafcb6998
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1517368
milestone66.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 1517368 - Expose PopupBlocker status via ChromeUtils - tests, r=smaug
dom/html/test/chrome.ini
dom/html/test/test_external_protocol_iframe.html
--- a/dom/html/test/chrome.ini
+++ b/dom/html/test/chrome.ini
@@ -2,8 +2,9 @@
 support-files =
   file_anchor_ping.html
   image.png
 
 [test_anchor_ping.html]
 skip-if = os == 'android'
 [test_bug1414077.html]
 [test_multipleFilePicker.html]
+[test_external_protocol_iframe.html]
new file mode 100644
--- /dev/null
+++ b/dom/html/test/test_external_protocol_iframe.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for external protocol URLs blocked for iframes</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+</head>
+<body>
+  <div id='foo'><a href='#'>Click here to test this issue</a></div>
+  <script>
+
+SimpleTest.waitForExplicitFinish();
+
+let foo = document.getElementById('foo');
+foo.addEventListener('click', _ => {
+  is(ChromeUtils.getPopupControlState(), "openAllowed", "Click events allow popups");
+  ok(!ChromeUtils.isPopupTokenUnused(), "Popup token has not been used yet");
+
+  for (let i = 0; i < 10; ++i) {
+    let ifr = document.createElement('iframe');
+    ifr.src = "foo+bar:all_good";
+    document.body.appendChild(ifr);
+
+    is(ChromeUtils.getPopupControlState(), "openAllowed", "Click events allow popups");
+    ok(ChromeUtils.isPopupTokenUnused(), "Popup token has been used!");
+  }
+
+  SimpleTest.finish();
+
+}, {once: true});
+
+setTimeout(_ => {
+  sendMouseEvent({type:'click'}, 'foo');
+}, 0);
+
+  </script>
+</body>
+</html>