diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-08 21:32:34 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-08 21:32:34 +0000 |
commit | 414785a5dce34bbe90b08c360992fd850612c2a1 (patch) | |
tree | 74a3f7b053dfc409afbc9187281dc0eac87160de /chrome/test | |
parent | 0df4ace4713e5b74a5215638111d514971aaf40d (diff) | |
download | chromium_src-414785a5dce34bbe90b08c360992fd850612c2a1.zip chromium_src-414785a5dce34bbe90b08c360992fd850612c2a1.tar.gz chromium_src-414785a5dce34bbe90b08c360992fd850612c2a1.tar.bz2 |
Ensure global extension events (like bookmarks) are sent to the incognito
extension process for split-mode extensions.
Also cleaned up some naming.
BUG=58189
TEST=no
Review URL: http://codereview.chromium.org/3578017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/extensions/api_test/incognito/split/background.html | 51 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/incognito/split/manifest.json | 2 |
2 files changed, 52 insertions, 1 deletions
diff --git a/chrome/test/data/extensions/api_test/incognito/split/background.html b/chrome/test/data/extensions/api_test/incognito/split/background.html index 32fec55..50ebea6 100644 --- a/chrome/test/data/extensions/api_test/incognito/split/background.html +++ b/chrome/test/data/extensions/api_test/incognito/split/background.html @@ -6,6 +6,27 @@ var assertTrue = chrome.test.assertTrue; var win, tab; var inIncognitoContext = chrome.extension.inIncognitoContext; +// Lifted from the bookmarks api_test. +function compareNode(left, right) { + //chrome.test.log("compareNode()"); + //chrome.test.log(JSON.stringify(left, null, 2)); + //chrome.test.log(JSON.stringify(right, null, 2)); + // TODO(erikkay): do some comparison of dateAdded + if (left.id != right.id) + return "id mismatch: " + left.id + " != " + right.id; + if (left.title != right.title) { + // TODO(erikkay): This resource dependency still isn't working reliably. + // See bug 19866. + // return "title mismatch: " + left.title + " != " + right.title; + chrome.test.log("title mismatch: " + left.title + " != " + right.title); + } + if (left.url != right.url) + return "url mismatch: " + left.url + " != " + right.url; + if (left.index != right.index) + return "index mismatch: " + left.index + " != " + right.index; + return true; +} + // Listen to some events to make sure we don't get events from the other // profile. @@ -84,6 +105,36 @@ chrome.test.runTests([ sendResponse(); done(); }); + }, + + // Tests that we can receive bookmarks events in both extension processes. + function bookmarkCreate() { + // Each process will create 1 bookmark, but expects to see updates from the + // other process. + var nodeNormal = {parentId:"1", title:"normal", url:"http://google.com/"}; + var nodeIncog = {parentId:"1", title:"incog", url:"http://google.com/"}; + var node = inIncognitoContext ? nodeIncog : nodeNormal; + var count = 0; + var done = chrome.test.listenForever(chrome.bookmarks.onCreated, + function(id, created) { + node = (created.title == nodeNormal.title) ? nodeNormal : nodeIncog; + node.id = created.id; + node.index = created.index; + chrome.test.assertEq(id, node.id); + chrome.test.assertTrue(compareNode(node, created)); + if (++count == 2) { + chrome.test.log("Bookmarks created. Incognito=" + inIncognitoContext); + done(); + } + }); + chrome.test.sendMessage("waiting", pass(function() { + chrome.bookmarks.create(node, pass(function(results) { + node.id = results.id; // since we couldn't know this going in + node.index = results.index; + chrome.test.assertTrue(compareNode(node, results), + "created node != source"); + })); + })); } ]); </script> diff --git a/chrome/test/data/extensions/api_test/incognito/split/manifest.json b/chrome/test/data/extensions/api_test/incognito/split/manifest.json index b3a9206..38efa71 100644 --- a/chrome/test/data/extensions/api_test/incognito/split/manifest.json +++ b/chrome/test/data/extensions/api_test/incognito/split/manifest.json @@ -4,5 +4,5 @@ "description": "test that an incognito extension in split mode behaves properly", "background_page": "background.html", "incognito": "split", - "permissions": ["tabs", "http://*/*"] + "permissions": ["tabs", "bookmarks", "http://*/*"] } |