tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug617528.xhtml (3122B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
      3 <?xml-stylesheet type="text/css"
      4                 href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
      5 <!--
      6 https://bugzilla.mozilla.org/show_bug.cgi?id=617528
      7 -->
      8 <window title="Mozilla Bug 617528"
      9        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     10 
     11  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     12  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
     13 
     14  <body xmlns="http://www.w3.org/1999/xhtml">
     15    <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=617528"
     16       target="_blank">Mozilla Bug 617528</a>
     17  </body>
     18 
     19  <script type="application/javascript"><![CDATA[
     20    const {BrowserTestUtils} = ChromeUtils.importESModule(
     21      "resource://testing-common/BrowserTestUtils.sys.mjs"
     22    );
     23    var _window;
     24    var browser;
     25 
     26    function start() {
     27      _window = window.browsingContext.topChromeWindow.open("window_bug617528.xhtml", "_new", "chrome");
     28      _window.addEventListener("load", onLoad);
     29    }
     30 
     31    function onLoad() {
     32      _window.removeEventListener("load", onLoad);
     33 
     34      browser = _window.document.getElementById("browser");
     35      browser.addEventListener("pageshow", onPageShow);
     36 
     37      var uri='data:text/html,\
     38 <html>\
     39  <body>\
     40    <div oncontextmenu="event.preventDefault()">\
     41      <input id="node" type="text" value="Click here"></input>\
     42    </div>\
     43  </body>\
     44 </html>';
     45      BrowserTestUtils.startLoadingURIString(browser, uri);
     46    }
     47 
     48    function onPageShow() {
     49      browser.removeEventListener("pageshow", onPageShow, true);
     50      SimpleTest.executeSoon(doTest);
     51    }
     52 
     53    function onContextMenu1(event) {
     54      is(event.defaultPrevented, true,
     55        "expected event.defaultPrevented to be true (1)");
     56      is(event.target.localName, "input",
     57        "expected event.target.localName to be 'input' (1)");
     58      is(event.originalTarget.localName, "div",
     59        "expected event.originalTarget.localName to be 'div' (1)");
     60    }
     61 
     62    function onContextMenu2(event) {
     63      is(event.defaultPrevented, false,
     64        "expected event.defaultPrevented to be false (2)");
     65      is(event.target.localName, "input",
     66        "expected event.target.localName to be 'input' (2)");
     67      is(event.originalTarget.localName, "div",
     68        "expected event.originalTarget.localName to be 'div' (2)");
     69    }
     70 
     71    function doTest() {
     72      var win = browser.contentWindow;
     73      win.focus();
     74      var node = win.document.getElementById("node");
     75 
     76      browser.addEventListener("contextmenu", onContextMenu1);
     77      synthesizeMouseAtCenter(node, { type: "contextmenu", button: 2 }, win);
     78      browser.removeEventListener("contextmenu", onContextMenu1);
     79 
     80      browser.addEventListener("contextmenu", onContextMenu2);
     81      synthesizeMouseAtCenter(node, { type: "contextmenu", button: 2, shiftKey: true }, win);
     82      browser.removeEventListener("contextmenu", onContextMenu2);
     83 
     84      _window.close();
     85      SimpleTest.finish();
     86    }
     87 
     88    addLoadEvent(start);
     89    SimpleTest.waitForExplicitFinish();
     90  ]]></script>
     91 </window>