Index: chrome/test/data/extensions/platform_apps/web_view/common/cleardata_persistent/bootstrap.js |
diff --git a/chrome/test/data/extensions/platform_apps/web_view/common/cleardata_persistent/bootstrap.js b/chrome/test/data/extensions/platform_apps/web_view/common/cleardata_persistent/bootstrap.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bdb7fdb45a54608d6da3b303bbe882bfa8274216 |
--- /dev/null |
+++ b/chrome/test/data/extensions/platform_apps/web_view/common/cleardata_persistent/bootstrap.js |
@@ -0,0 +1,69 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+config.IS_CHROME_TEST = true; |
+// Guest served from TestServer. |
+config.IS_JS_ONLY_GUEST = false; |
+config.TEST_DIR = 'cleardata_persistent'; |
+ |
+var clearDataTests = {}; |
+ |
+// step1. Ask guest to load load session (bar) and persistent (foo) cookies. |
+// step2. Guest responds saying it has added cookies. |
+// embedder clears persistent cookie data of the guest via clearData API. |
+// step3. Ask guest for cookies that were set in step1. |
+// step4. Guest responds with cookie values, embedder verifies persistent cookie |
+// is unset but session cookie is still set. |
+ |
+var run = function() { |
+ var container = document.createElement('div'); |
+ container.id = 'webview-tag-container'; |
+ document.body.appendChild(container); |
+ |
+ chrome.test.getConfig(function(chromeConfig) { |
+ window.console.log('getConfig: ' + chromeConfig); |
+ utils.setUp(chromeConfig, config); |
+ embedder.loadGuest(function() { |
+ chrome.test.runTests([ |
+ clearDataTests.testCookies |
+ ]); |
+ }, function(data) { |
+ var handled = true; |
+ switch (data[0]) { |
+ case 'step2.cookies-added': |
+ window.console.log('embedder, on message: ' + data[0]); |
+ var onDataCleared = function() { |
+ window.console.log('embedder.onDataCleared'); |
+ embedder.webview.contentWindow.postMessage( |
+ JSON.stringify(['step3.get-cookies', 'foo', 'bar']), '*'); |
+ }; |
+ embedder.webview.clearData( |
+ { 'since': 1 }, { 'persistentCookies': true }, |
+ onDataCleared); |
+ break; |
+ case 'step4.got-cookies': |
+ window.console.log('embedder, on message: ' + data[0]); |
+ var cookies = data[1]; |
+ // fooValue was a persistent cookie, which should be gone. |
+ chrome.test.assertEq([null, 'barValue'], cookies); |
+ chrome.test.succeed(); |
+ break; |
+ default: |
+ handled = false; |
+ break; |
+ } |
+ return handled; |
+ }); |
+ }); |
+}; |
+ |
+// Tests. |
+clearDataTests.testCookies = function testCookies() { |
+ window.console.log('clearDataTests.testCookies'); |
+ embedder.webview.contentWindow.postMessage( |
+ JSON.stringify(['step1.add-cookies']), '*'); |
+}; |
+ |
+// Run test(s). |
+run(); |