Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="inspector-protocol-test.js"></script> | |
| 5 <script> | |
| 6 function test() | |
| 7 { | |
| 8 InspectorTest.log("Test started"); | |
| 9 | |
| 10 // Todo(allada) Many of these methods appear to be syncronious but are actua lly async in backend, we should address this. | |
| 11 var testCookies = [ | |
| 12 function simpleCookieAdd(done) | |
| 13 { | |
| 14 setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar"}, done); | |
| 15 }, | |
| 16 function simpleCookieChange(done) | |
| 17 { | |
| 18 setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "second bar"}, done); | |
| 19 }, | |
| 20 function simpleCookieDelete(done) | |
| 21 { | |
| 22 deleteCookie({url: "http://127.0.0.1:8000", name: "foo"}, done); | |
| 23 }, | |
| 24 function sessionCookieAdd(done) | |
| 25 { | |
| 26 setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar", expirationDate: undefined}, done); | |
| 27 }, | |
| 28 deleteAllCookies, | |
| 29 function nonSessionCookieZeroAdd(done) | |
| 30 { | |
| 31 setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar", expirationDate: 0}, done); | |
| 32 }, | |
| 33 deleteAllCookies, | |
|
dgozman
2016/08/09 01:07:25
Empty lines please.
allada
2016/08/10 02:46:54
Done.
| |
| 34 function nonSessionCookieAdd(done) | |
| 35 { | |
| 36 setCookie({url: "http://127.0.0.1:8000", name: "foo", value: "bar", expirationDate: new Date().getTime() + 1000000}, done); | |
| 37 }, | |
| 38 function invalidCookieAdd(done) | |
| 39 { | |
| 40 setCookie({url: "http://example.com", name: "foo", value: "bar"}, do ne); | |
| 41 } | |
| 42 ]; | |
| 43 | |
| 44 enableNetwork(); | |
| 45 | |
| 46 function enableNetwork() | |
| 47 { | |
| 48 InspectorTest.log("Enabling network"); | |
| 49 InspectorTest.sendCommandOrDie("Network.enable", {}, InspectorTest.runTe stSuite(testCookies)); | |
| 50 } | |
| 51 | |
| 52 function setCookie(cookie, done) | |
| 53 { | |
| 54 InspectorTest.log("Setting Cookie"); | |
| 55 InspectorTest.sendCommandOrDie("Network.setCookie", cookie, () => logCoo kies(done)); | |
| 56 } | |
| 57 | |
| 58 function deleteCookie(cookie, done) | |
| 59 { | |
| 60 InspectorTest.log("Deleting Cookie"); | |
| 61 InspectorTest.sendCommandOrDie("Network.deleteCookie", cookie, () => log Cookies(done)); | |
| 62 } | |
| 63 | |
| 64 function deleteAllCookies(done) | |
| 65 { | |
| 66 InspectorTest.log("Removing All Cookies"); | |
| 67 InspectorTest.sendCommandOrDie("Network.canClearBrowserCookies", {}, () => logCookies(done)); | |
| 68 } | |
| 69 | |
| 70 function logCookies(done) | |
| 71 { | |
| 72 InspectorTest.log("Logging Cookies"); | |
| 73 InspectorTest.sendCommandOrDie("Network.getCookies", {}, logReceivedGetC ookies.bind(null, done)); | |
| 74 } | |
| 75 function logReceivedGetCookies(done, data) | |
| 76 { | |
| 77 InspectorTest.log("Num of cookies " + data.cookies.length); | |
| 78 for (var cookie of data.cookies) { | |
| 79 InspectorTest.log(" Cookie: "); | |
| 80 InspectorTest.log(" Domain: " + cookie.domain); | |
| 81 InspectorTest.log(" Name: " + cookie.name); | |
| 82 InspectorTest.log(" Value: " + cookie.value); | |
| 83 InspectorTest.log(" Path: " + cookie.path); | |
| 84 InspectorTest.log(" HttpOnly: " + cookie.httpOnly); | |
| 85 InspectorTest.log(" Secure: " + cookie.secure); | |
| 86 InspectorTest.log(" Session: " + cookie.session); | |
| 87 } | |
| 88 done(); | |
| 89 } | |
| 90 } | |
| 91 </script> | |
| 92 </head> | |
| 93 <body onload="runTest();"> | |
| 94 <p>Tests that cookies are set, updated and removed.</p> | |
| 95 </body> | |
| 96 </html> | |
| OLD | NEW |