summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-02 13:36:16 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-02 13:36:16 +0100
commit390894c822f1b163f16744646372a28c0d93a89e (patch)
tree29b6368ffd292bafcc098a0215cb83d0a7a925ec /devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
parente272829137195b46612b7664c9416364089f7baa (diff)
downloadUXP-390894c822f1b163f16744646372a28c0d93a89e.tar
UXP-390894c822f1b163f16744646372a28c0d93a89e.tar.gz
UXP-390894c822f1b163f16744646372a28c0d93a89e.tar.lz
UXP-390894c822f1b163f16744646372a28c0d93a89e.tar.xz
UXP-390894c822f1b163f16744646372a28c0d93a89e.zip
Bug 1146194: Multiple cookies with the same name not shown
Issue #31
Diffstat (limited to 'devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js')
-rw-r--r--devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js105
1 files changed, 105 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js b/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
new file mode 100644
index 000000000..c1cf0aa72
--- /dev/null
+++ b/devtools/server/tests/browser/browser_storage_cookies-duplicate-names.js
@@ -0,0 +1,105 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that the storage panel is able to display multiple cookies with the same
+// name (and different paths).
+
+const {StorageFront} = require("devtools/shared/fronts/storage");
+Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtools/server/tests/browser/storage-helpers.js", this);
+
+const TESTDATA = {
+ "test1.example.org": [
+ {
+ name: "name",
+ value: "value1",
+ expires: 0,
+ path: "/",
+ host: "test1.example.org",
+ isDomain: false,
+ isSecure: false,
+ },
+ {
+ name: "name",
+ value: "value2",
+ expires: 0,
+ path: "/path2/",
+ host: "test1.example.org",
+ isDomain: false,
+ isSecure: false,
+ },
+ {
+ name: "name",
+ value: "value3",
+ expires: 0,
+ path: "/path3/",
+ host: "test1.example.org",
+ isDomain: false,
+ isSecure: false,
+ }
+ ]
+};
+
+add_task(function* () {
+ yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies-same-name.html");
+
+ initDebuggerServer();
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
+ let form = yield connectDebuggerClient(client);
+ let front = StorageFront(client, form);
+ let data = yield front.listStores();
+
+ ok(data.cookies, "Cookies storage actor is present");
+
+ yield testCookies(data.cookies);
+ yield clearStorage();
+
+ // Forcing GC/CC to get rid of docshells and windows created by this test.
+ forceCollections();
+ yield client.close();
+ forceCollections();
+ DebuggerServer.destroy();
+ forceCollections();
+});
+
+function testCookies(cookiesActor) {
+ let numHosts = Object.keys(cookiesActor.hosts).length;
+ is(numHosts, 1, "Correct number of host entries for cookies");
+ return testCookiesObjects(0, cookiesActor.hosts, cookiesActor);
+}
+
+var testCookiesObjects = Task.async(function* (index, hosts, cookiesActor) {
+ let host = Object.keys(hosts)[index];
+ let matchItems = data => {
+ is(data.total, TESTDATA[host].length,
+ "Number of cookies in host " + host + " matches");
+ for (let item of data.data) {
+ let found = false;
+ for (let toMatch of TESTDATA[host]) {
+ if (item.name === toMatch.name &&
+ item.host === toMatch.host &&
+ item.path === toMatch.path) {
+ found = true;
+ ok(true, "Found cookie " + item.name + " in response");
+ is(item.value.str, toMatch.value, "The value matches.");
+ is(item.expires, toMatch.expires, "The expiry time matches.");
+ is(item.path, toMatch.path, "The path matches.");
+ is(item.host, toMatch.host, "The host matches.");
+ is(item.isSecure, toMatch.isSecure, "The isSecure value matches.");
+ is(item.isDomain, toMatch.isDomain, "The isDomain value matches.");
+ break;
+ }
+ }
+ ok(found, "cookie " + item.name + " should exist in response");
+ }
+ };
+
+ ok(!!TESTDATA[host], "Host is present in the list : " + host);
+ matchItems(yield cookiesActor.getStoreObjects(host));
+ if (index == Object.keys(hosts).length - 1) {
+ return;
+ }
+ yield testCookiesObjects(++index, hosts, cookiesActor);
+});