Commit c3c33b0a authored by Mounir Lamouri's avatar Mounir Lamouri
Browse files

Bug 709448 - File input click() handling should perhaps allow openControlled popups; r=bz

parent 22b43d33
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ AsyncClickHandler::Run()
  }

  // Check if page is allowed to open the popup
  if (mPopupControlState != openAllowed) {
  if (mPopupControlState > openControlled) {
    nsCOMPtr<nsIPopupWindowManager> pm =
      do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID);

+17 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=36619
  <input id='a' type='file'>
</div>
<button id='b' onclick="document.getElementById('a').click();">Show Filepicker</button>
<button id='c' onmousedown="document.getElementById('a').click();">Show Filepicker</button>
<button id='d' onmouseup="document.getElementById('a').click();">Show Filepicker</button>
<pre id="test">
<script type="application/javascript">

@@ -36,7 +38,7 @@ SpecialPowers.pushPrefEnv({'set': [
    // Tests that a click on 'b' calls the show method.
    var b = document.getElementById('b');
    b.focus(); // Be sure the element is visible.
    synthesizeMouse(b, 2, 2, {});
    synthesizeMouseAtCenter(b, {});
    SimpleTest.executeSoon(function() {
      ok(MockFilePicker.shown, "File picker show method should have been called");
      MockFilePicker.reset();
@@ -45,13 +47,25 @@ SpecialPowers.pushPrefEnv({'set': [
      document.getElementById("a").click();
      SimpleTest.executeSoon(function() {
        ok(!MockFilePicker.shown, "File picker show method should not have been called");
        MockFilePicker.cleanup();
        MockFilePicker.reset();

        synthesizeMouseAtCenter(document.getElementById('c'), {});
        SimpleTest.executeSoon(function() {
          ok(!MockFilePicker.shown, "File picker show method should have been called");
          MockFilePicker.reset();

          synthesizeMouseAtCenter(document.getElementById('d'), {});
          SimpleTest.executeSoon(function() {
            ok(MockFilePicker.shown, "File picker show method should have been called");

            MockFilePicker.cleanup();
            SimpleTest.finish();
          });
        });
      });
    });
  });
});

</script>
</pre>