Bug 1437057 - Expose the origin of a cookie to JS - tests, r=mayhemer

Differential Revision: https://phabricator.services.mozilla.com/D67590

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2020-03-24 17:52:41 +00:00
Родитель bd961ae216
Коммит 400b195fb8
2 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -14,3 +14,4 @@ support-files =
[test_metaTag.html]
[test_xmlDocument.html]
support-files = empty.html
[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>