Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
lazyboy
2017/02/15 21:45:26
here and other places: 2017
Also my comments in e
lfg
2017/02/15 22:44:00
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 config.IS_CHROME_TEST = true; | |
| 6 // Guest served from TestServer. | |
| 7 config.IS_JS_ONLY_GUEST = false; | |
| 8 config.TEST_DIR = 'cleardata_persistent'; | |
| 9 | |
| 10 var clearDataTests = {}; | |
| 11 | |
| 12 // step1. Ask guest to load some cookie. | |
| 13 // step2. Guest responds saying it has added cookies. | |
| 14 // embedder clears cookie data of the guest via clearData API. | |
| 15 // step3. Ask guest for cookies that were set in step1. | |
| 16 // step4. Guest responds with cookie values, embedder verifies they are unset. | |
| 17 | |
| 18 var run = function() { | |
| 19 var container = document.createElement('div'); | |
| 20 container.id = 'webview-tag-container'; | |
| 21 document.body.appendChild(container); | |
| 22 | |
| 23 chrome.test.getConfig(function(chromeConfig) { | |
| 24 window.console.log('getConfig: ' + chromeConfig); | |
| 25 utils.setUp(chromeConfig, config); | |
| 26 embedder.loadGuest(function() { | |
| 27 chrome.test.runTests([ | |
| 28 clearDataTests.testCookies | |
| 29 ]); | |
| 30 }, function(data) { | |
| 31 var handled = true; | |
| 32 switch (data[0]) { | |
| 33 case 'step2.cookies-added': | |
| 34 window.console.log('embedder, on message: ' + data[0]); | |
| 35 var onDataCleared = function() { | |
| 36 window.console.log('embedder.onDataCleared'); | |
| 37 embedder.webview.contentWindow.postMessage( | |
| 38 JSON.stringify(['step3.get-cookies', 'foo', 'bar']), '*'); | |
| 39 }; | |
| 40 embedder.webview.clearData( | |
| 41 { 'since': 1}, { 'persistentCookies': true }, | |
|
lazyboy
2017/02/15 21:45:26
rm space before 'since'
lfg
2017/02/15 22:44:00
Done.
| |
| 42 onDataCleared); | |
| 43 break; | |
| 44 case 'step4.got-cookies': | |
| 45 window.console.log('embedder, on message: ' + data[0]); | |
| 46 var cookies = data[1]; | |
| 47 chrome.test.assertEq([null, 'barValue'], cookies); | |
| 48 chrome.test.succeed(); | |
| 49 break; | |
| 50 default: | |
| 51 handled = false; | |
| 52 break; | |
| 53 } | |
| 54 return handled; | |
| 55 }); | |
| 56 }); | |
| 57 }; | |
| 58 | |
| 59 // Tests. | |
| 60 clearDataTests.testCookies = function testCookies() { | |
| 61 window.console.log('clearDataTests.testCookies'); | |
| 62 embedder.webview.contentWindow.postMessage( | |
| 63 JSON.stringify(['step1.add-cookies']), '*'); | |
| 64 }; | |
| 65 | |
| 66 // Run test(s). | |
| 67 run(); | |
| OLD | NEW |