Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/cookies-protocol-test.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/cookies-protocol-test.html b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/cookies-protocol-test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..07c860d3c1a0242a284e0e705b8c4b6e13de5714 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/cookies-protocol-test.html |
| @@ -0,0 +1,96 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<script src="inspector-protocol-test.js"></script> |
| +<script> |
| +function test() |
| +{ |
| + InspectorTest.log("Test started"); |
| + |
| + // Todo(allada) Many of these methods appear to be syncronious but are actually async in backend, we should address this. |
| + var testCookies = [ |
| + function simpleCookieAdd(done) |
| + { |
| + setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar"}, done); |
| + }, |
| + function simpleCookieChange(done) |
| + { |
| + setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "second bar"}, done); |
| + }, |
| + function simpleCookieDelete(done) |
| + { |
| + deleteCookie({url: "http://127.0.0.1:8000", name: "foo"}, done); |
| + }, |
| + function sessionCookieAdd(done) |
| + { |
| + setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar", expirationDate: undefined}, done); |
| + }, |
| + deleteAllCookies, |
| + function nonSessionCookieZeroAdd(done) |
| + { |
| + setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar", expirationDate: 0}, done); |
| + }, |
| + deleteAllCookies, |
|
dgozman
2016/08/09 01:07:25
Empty lines please.
allada
2016/08/10 02:46:54
Done.
|
| + function nonSessionCookieAdd(done) |
| + { |
| + setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar", expirationDate: new Date().getTime() + 1000000}, done); |
| + }, |
| + function invalidCookieAdd(done) |
| + { |
| + setCookie({url: "http://example.com", name: "foo", value: "bar"}, done); |
| + } |
| + ]; |
| + |
| + enableNetwork(); |
| + |
| + function enableNetwork() |
| + { |
| + InspectorTest.log("Enabling network"); |
| + InspectorTest.sendCommandOrDie("Network.enable", {}, InspectorTest.runTestSuite(testCookies)); |
| + } |
| + |
| + function setCookie(cookie, done) |
| + { |
| + InspectorTest.log("Setting Cookie"); |
| + InspectorTest.sendCommandOrDie("Network.setCookie", cookie, () => logCookies(done)); |
| + } |
| + |
| + function deleteCookie(cookie, done) |
| + { |
| + InspectorTest.log("Deleting Cookie"); |
| + InspectorTest.sendCommandOrDie("Network.deleteCookie", cookie, () => logCookies(done)); |
| + } |
| + |
| + function deleteAllCookies(done) |
| + { |
| + InspectorTest.log("Removing All Cookies"); |
| + InspectorTest.sendCommandOrDie("Network.canClearBrowserCookies", {}, () => logCookies(done)); |
| + } |
| + |
| + function logCookies(done) |
| + { |
| + InspectorTest.log("Logging Cookies"); |
| + InspectorTest.sendCommandOrDie("Network.getCookies", {}, logReceivedGetCookies.bind(null, done)); |
| + } |
| + function logReceivedGetCookies(done, data) |
| + { |
| + InspectorTest.log("Num of cookies " + data.cookies.length); |
| + for (var cookie of data.cookies) { |
| + InspectorTest.log(" Cookie: "); |
| + InspectorTest.log(" Domain: " + cookie.domain); |
| + InspectorTest.log(" Name: " + cookie.name); |
| + InspectorTest.log(" Value: " + cookie.value); |
| + InspectorTest.log(" Path: " + cookie.path); |
| + InspectorTest.log(" HttpOnly: " + cookie.httpOnly); |
| + InspectorTest.log(" Secure: " + cookie.secure); |
| + InspectorTest.log(" Session: " + cookie.session); |
| + } |
| + done(); |
| + } |
| +} |
| +</script> |
| +</head> |
| +<body onload="runTest();"> |
| +<p>Tests that cookies are set, updated and removed.</p> |
| +</body> |
| +</html> |