Bug 1437057 - Expose the origin of a cookie to JS - tests, r=mayhemer
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 24 Mar 2020 17:52:41 +0000
changeset 520255 e22128209b5092c565c2a601ac82b706feeddd25
parent 520254 6bd429e30868ccaeba7a03f4aff7fc282c025d4d
child 520256 44cdc3311ba7c47f487235e7fd8a5f1fc428dec9
push id37246
push useropoprus@mozilla.com
push dateWed, 25 Mar 2020 03:40:33 +0000
treeherdermozilla-central@14b59d4adc95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1437057
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1437057 - Expose the origin of a cookie to JS - tests, r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D67590
netwerk/cookie/test/mochitest/mochitest.ini
netwerk/cookie/test/mochitest/test_document_cookie_notification.html
--- a/netwerk/cookie/test/mochitest/mochitest.ini
+++ b/netwerk/cookie/test/mochitest/mochitest.ini
@@ -9,8 +9,9 @@ support-files =
 [test_image.html]
 [test_script.html]
 [test_sharedWorker.html]
 [test_worker.html]
 [test_xhr.html]
 [test_metaTag.html]
 [test_xmlDocument.html]
 support-files = empty.html
+[test_document_cookie_notification.html]
new file mode 100644
--- /dev/null
+++ b/netwerk/cookie/test/mochitest/test_document_cookie_notification.html
@@ -0,0 +1,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>