tor-browser

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

test_bug339494.xhtml (2325B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=339494
      6 -->
      7 <window title="Mozilla Bug 339494"
      8  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      9  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     10 
     11  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     12 
     13 <body  xmlns="http://www.w3.org/1999/xhtml">
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=339494">Mozilla Bug 339494</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none">
     17  <xul:hbox id="d"/>
     18  <xul:hbox id="s"/>
     19 </div>
     20 <pre id="test">
     21 </pre>
     22 </body>
     23 
     24 <script class="testbody" type="application/javascript">
     25 
     26 /** Test for Bug 339494 */
     27 SimpleTest.waitForExplicitFinish();
     28 
     29 (async function runTests() {
     30  function promiseFlushingMutationObserver() {
     31    return new Promise(SimpleTest.executeSoon);
     32  }
     33 
     34  await (async function() {
     35    const d = document.getElementById("d");
     36 
     37    d.setAttribute("hhh", "testvalue");
     38    await promiseFlushingMutationObserver();
     39 
     40    const observer = new MutationObserver((aMutationList, aObserver) => {
     41      ok(!d.hasAttribute("hhh"), "Value check 1. There should be no value");
     42      isnot(d.getAttribute("hhh"), "testvalue", "Value check 2");
     43      aObserver.disconnect();
     44      d.removeAttribute("hhh");
     45      ok(true, "Reachability. We shouldn't have crashed");
     46    });
     47    observer.observe(d, { attributes: true });
     48    d.removeAttribute("hhh");
     49    await promiseFlushingMutationObserver();
     50  })();
     51 
     52  await (async function() {
     53    const s = document.getElementById("s");
     54 
     55    s.setAttribute("ggg", "testvalue");
     56    await promiseFlushingMutationObserver();
     57 
     58    const observer = new MutationObserver(() => {
     59      ok(s.hasAttribute("ggg"), "Value check 3. There should be a value");
     60      isnot(s.getAttribute("ggg"), "testvalue", "Value check 4");
     61      is(s.getAttribute("ggg"), "othervalue", "Value check 5");
     62    });
     63    observer.observe(s, { attributes: true });
     64    s.setAttribute("ggg", "othervalue");
     65    await promiseFlushingMutationObserver();
     66    observer.disconnect();
     67  })();
     68 
     69  SimpleTest.finish();
     70 })();
     71 </script>
     72 
     73 </window>