summaryrefslogtreecommitdiffstats
path: root/netwerk/cookie/test/mochitest/test_document_cookie_notification.html
blob: b84b6ed045d45d89d98501337bf4b51a179fe0bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for document.cookie setter + notification</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>

<script type="application/javascript">

function Listener() {
  SpecialPowers.addObserver(this, "document-set-cookie");
}

Listener.prototype = {
  observe(aSubject, aTopic, aData) {
    is(aTopic, "document-set-cookie", "Notification received");
    ok(aData.startsWith("a="), "Right cookie received");

    SpecialPowers.removeObserver(this, "document-set-cookie");
    SimpleTest.finish();
  }
}

const cl = new Listener();
document.cookie = "a=" + Math.random();
SimpleTest.waitForExplicitFinish();

</script>
</body>
</html>