зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
bd961ae216
Коммит
400b195fb8
|
@ -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>
|
Загрузка…
Ссылка в новой задаче