tor-browser

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

test_document_cookie_notification.html (775B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for document.cookie setter + notification</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      7 </head>
      8 <body>
      9 
     10 <script type="application/javascript">
     11 
     12 function Listener() {
     13  SpecialPowers.addObserver(this, "document-set-cookie");
     14 }
     15 
     16 Listener.prototype = {
     17  observe(aSubject, aTopic, aData) {
     18    is(aTopic, "document-set-cookie", "Notification received");
     19    ok(aData.startsWith("a="), "Right cookie received");
     20 
     21    SpecialPowers.removeObserver(this, "document-set-cookie");
     22    SimpleTest.finish();
     23  }
     24 }
     25 
     26 const cl = new Listener();
     27 document.cookie = "a=" + Math.random();
     28 SimpleTest.waitForExplicitFinish();
     29 
     30 </script>
     31 </body>
     32 </html>