diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 19:07:21 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 19:07:21 +0000 |
commit | 5592d7ec9c8b63cca9ab980d4c2d9888dafc3761 (patch) | |
tree | b84940449246e80d5db8ad0e2aefa718a1e86bd9 /chrome/test/data | |
parent | 6a2da2a134813c7820f89d6c750287663bfed078 (diff) | |
download | chromium_src-5592d7ec9c8b63cca9ab980d4c2d9888dafc3761.zip chromium_src-5592d7ec9c8b63cca9ab980d4c2d9888dafc3761.tar.gz chromium_src-5592d7ec9c8b63cca9ab980d4c2d9888dafc3761.tar.bz2 |
Extension API Renaming/Consistency changes
BUG=20288
Review URL: http://codereview.chromium.org/180016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data')
11 files changed, 182 insertions, 90 deletions
diff --git a/chrome/test/data/extensions/browsertest/last_error/toolstrip.html b/chrome/test/data/extensions/browsertest/last_error/toolstrip.html index 01af2af..6df972e 100755 --- a/chrome/test/data/extensions/browsertest/last_error/toolstrip.html +++ b/chrome/test/data/extensions/browsertest/last_error/toolstrip.html @@ -18,7 +18,7 @@ function testLastError() { var maxTabId = 0; // Find the highest tab id - chrome.windows.getAll(true, function(windows) { + chrome.windows.getAll({populate:true}, function(windows) { // Make sure lastError is still not set. (this call have should succeeded). if (chrome.tabs.lastError) fail(); diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js index feacd93..34d27fc 100644 --- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js +++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/page.js @@ -18,6 +18,8 @@ win.onload = function() { port.disconnect(); } else if (msg.testDisconnectOnClose) { win.location = "about:blank"; + } else if (msg.testPortName) { + port.postMessage({portName:port.name}); } // Ignore other messages since they are from us. }); @@ -27,10 +29,11 @@ win.onload = function() { // Tests that postMessage to the extension and its response works. function testPostMessageFromTab(origPort) { console.log('testPostMessageFromTab'); - var port = chrome.extension.connect(); + var portName = "peter"; + var port = chrome.extension.connect({name: portName}); port.postMessage({testPostMessageFromTab: true}); port.onMessage.addListener(function(msg) { - origPort.postMessage({success: msg.success}); + origPort.postMessage({success: (msg.success && (msg.portName == portName))}); console.log('sent ' + msg.success); port.disconnect(); }); diff --git a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html index a8bfe7e..84c7db0 100644 --- a/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html +++ b/chrome/test/data/extensions/good/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/toolstrip.html @@ -1,65 +1,80 @@ -<script>
-window.onload = function() {
- chrome.extension.onConnect.addListener(function(port) {
- console.log('onConnect');
- port.onMessage.addListener(function(msg) {
- console.log('got message');
- if (msg.testPostMessageFromTab) {
- port.postMessage({success: true});
- console.log('sent success');
- }
- // Ignore other messages since they are from us.
- });
- });
-};
-
-// Tests that postMessage to the tab and its response works.
-function testPostMessage() {
- chrome.tabs.getSelected(null, function(tab) {
- var port = chrome.tabs.connect(tab.id);
- console.log('connect to ' + tab.id);
- port.postMessage({testPostMessage: true});
- port.onMessage.addListener(function(msg) {
- window.domAutomationController.send(msg.success);
- port.disconnect();
- });
- });
-}
-
-// Tests that postMessage from the tab and its response works.
-function testPostMessageFromTab() {
- chrome.tabs.getSelected(null, function(tab) {
- var port = chrome.tabs.connect(tab.id);
- console.log('connect to ' + tab.id);
- port.postMessage({testPostMessageFromTab: true});
- port.onMessage.addListener(function(msg) {
- window.domAutomationController.send(msg.success);
- port.disconnect();
- });
- });
-}
-
-// Tests that we get the disconnect event when the tab disconnect.
-function testDisconnect() {
- chrome.tabs.getSelected(null, function(tab) {
- var port = chrome.tabs.connect(tab.id);
- console.log('connect to ' + tab.id);
- port.postMessage({testDisconnect: true});
- port.onDisconnect.addListener(function() {
- window.domAutomationController.send(true);
- });
- });
-}
-
-// Tests that we get the disconnect event when the tab context closes.
-function testDisconnectOnClose() {
- chrome.tabs.getSelected(null, function(tab) {
- var port = chrome.tabs.connect(tab.id);
- console.log('connect to ' + tab.id);
- port.postMessage({testDisconnectOnClose: true});
- port.onDisconnect.addListener(function() {
- window.domAutomationController.send(true);
- });
- });
-}
-</script>
+<script> +window.onload = function() { + chrome.extension.onConnect.addListener(function(port) { + console.log('onConnect'); + port.onMessage.addListener(function(msg) { + console.log('got message'); + if (msg.testPostMessageFromTab) { + port.postMessage({success: true, portName: port.name}); + console.log('sent success'); + } + // Ignore other messages since they are from us. + }); + }); +}; + +// Tests that postMessage to the tab and its response works. +function testPostMessage() { + chrome.tabs.getSelected(null, function(tab) { + var port = chrome.tabs.connect(tab.id); + console.log('connect to ' + tab.id); + port.postMessage({testPostMessage: true}); + port.onMessage.addListener(function(msg) { + window.domAutomationController.send(msg.success); + port.disconnect(); + }); + }); +} + +// Tests that port name is sent & received correctly. +function testPortName() { + chrome.tabs.getSelected(null, function(tab) { + var portName = "lemonjello"; + var port = chrome.tabs.connect(tab.id, {name: portName}); + console.log('naming port ' + portName); + port.postMessage({testPortName: true}); + port.onMessage.addListener(function(msg) { + console.log('got name ' + msg.portName); + window.domAutomationController.send(msg.portName == portName); + port.disconnect(); + }); + }); +} + +// Tests that postMessage from the tab and its response works. +function testPostMessageFromTab() { + chrome.tabs.getSelected(null, function(tab) { + var port = chrome.tabs.connect(tab.id); + console.log('connect to ' + tab.id); + port.postMessage({testPostMessageFromTab: true}); + port.onMessage.addListener(function(msg) { + window.domAutomationController.send(msg.success); + port.disconnect(); + }); + }); +} + +// Tests that we get the disconnect event when the tab disconnect. +function testDisconnect() { + chrome.tabs.getSelected(null, function(tab) { + var port = chrome.tabs.connect(tab.id); + console.log('connect to ' + tab.id); + port.postMessage({testDisconnect: true}); + port.onDisconnect.addListener(function() { + window.domAutomationController.send(true); + }); + }); +} + +// Tests that we get the disconnect event when the tab context closes. +function testDisconnectOnClose() { + chrome.tabs.getSelected(null, function(tab) { + var port = chrome.tabs.connect(tab.id); + console.log('connect to ' + tab.id); + port.postMessage({testDisconnectOnClose: true}); + port.onDisconnect.addListener(function() { + window.domAutomationController.send(true); + }); + }); +} +</script> diff --git a/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html b/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html index 886b43f..7421ad6 100644 --- a/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html +++ b/chrome/test/data/extensions/samples/bookmarks/bookmark_api.html @@ -34,7 +34,7 @@ var testMoveBookmarks2 = function(event) { return; } console.log("testMoveBookmarks2"); - chrome.bookmarks.getChildren(0, function(root_children) { + chrome.bookmarks.getChildren('0', function(root_children) { var bookmark_bar = root_children[0]; // bookmarks bar is always first chrome.bookmarks.getChildren(bookmark_bar.id, function(bar_children) { var folder_search = []; @@ -74,7 +74,7 @@ var testMoveBookmarks2 = function(event) { }; var dumpBookmarks = function(event) { - window.open("bookmark_view.html"); + chrome.tabs.create({url:"bookmark_view.html"}); }; </script> <body> diff --git a/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html b/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html index 5275f37..163f2e4 100644 --- a/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html +++ b/chrome/test/data/extensions/samples/bookmarks/bookmark_view.html @@ -43,8 +43,8 @@ var logEvent = function(name, id, data) { console.log("got event: " + name); } -chrome.bookmarks.onAdded.addListener(function(id, data) { - logEvent("onBookmarkAdded", id, data); +chrome.bookmarks.onCreated.addListener(function(id, data) { + logEvent("onBookmarkCreated", id, data); }); chrome.bookmarks.onRemoved.addListener(function(id, data) { @@ -71,9 +71,7 @@ var toggleBookmark = function(event) { var id_str = node.id; if (id_str < prefix.length) return; - var id = parseInt(id_str.substring(prefix.length)); - if (id == NaN) - return; + var id = id_str.substring(prefix.length); console.log("toggle: " + id); //console.dir(event); if (node.childNodes.length > 1) { @@ -136,7 +134,7 @@ var testGetTree = function(results) { var loadBookmarks = function() { var container = document.getElementById('container'); var rootElement = document.createElement("div"); - var rootId = 0; + var rootId = '0'; rootElement.id = prefix + rootId; // root element is empty / invisible, just an id to be looked up container.appendChild(rootElement); diff --git a/chrome/test/data/extensions/samples/bookmarks/manifest.json b/chrome/test/data/extensions/samples/bookmarks/manifest.json index 1580ca7..c6319e8 100644 --- a/chrome/test/data/extensions/samples/bookmarks/manifest.json +++ b/chrome/test/data/extensions/samples/bookmarks/manifest.json @@ -2,5 +2,6 @@ "name": "BookmarksAPI",
"description": "Bookmarks API test",
"version": "0.1",
- "toolstrips": ["bookmark_api.html"]
+ "toolstrips": ["bookmark_api.html"],
+ "permissions": ["bookmarks"]
}
diff --git a/chrome/test/data/extensions/samples/mole/manifest.json b/chrome/test/data/extensions/samples/mole/manifest.json new file mode 100755 index 0000000..f6916ce --- /dev/null +++ b/chrome/test/data/extensions/samples/mole/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "Mole", + "description": "Test animated popup moles", + "version": "0.1", + "toolstrips": ["mole.html"], + "permissions": ["tabs"] +} diff --git a/chrome/test/data/extensions/samples/mole/mole.html b/chrome/test/data/extensions/samples/mole/mole.html new file mode 100755 index 0000000..9efad76 --- /dev/null +++ b/chrome/test/data/extensions/samples/mole/mole.html @@ -0,0 +1,67 @@ +<html> + <head> + <style> + +body { + -webkit-box-orient:vertical; + -webkit-box-direction:normal; +} + +body { + width: 100px; +} + +.toolstrip, .toolstrip-content { + -webkit-box-orient: horizonal; + white-space:nowrap; + overflow: hidden; + margin:0; + padding:0; + width: 100%; +} + +.toolstrip { + height: 23px; + -webkit-box-align: center; + border: 1px solid grey; +} + + + +.toolstrip-content { + -webkit-box-flex: 1; + background-color: white; + color: black; +} + + </style> + <script> +var collapsed = true; + +function toggle() { + if (collapsed) { + chrome.toolstrip.expand({ height: 400 }, function() { + document.getElementById('content').style.display = "-webkit-box"; + collapsed = false; + }); + } else { + chrome.toolstrip.collapse(undefined, function() { + document.getElementById('content').style.display = "none"; + collapsed = true; + }); + } +} +</script> + </head> + <body> + + <div id="content" style="display:none" class="toolstrip-content"> + Content + </div> + <div onclick="toggle();" class="toolstrip"> + Toolstrip + </div> + + </body> +</html> + diff --git a/chrome/test/data/extensions/samples/subscribe_page_action/background.html b/chrome/test/data/extensions/samples/subscribe_page_action/background.html index 4d14440..e77d2e4 100644 --- a/chrome/test/data/extensions/samples/subscribe_page_action/background.html +++ b/chrome/test/data/extensions/samples/subscribe_page_action/background.html @@ -33,9 +33,10 @@ }); // Chrome will call into us when the user clicks on the icon in the OmniBox. - chrome.pageActions["RssPageAction"].addListener(function(reply) { + chrome.pageActions["RssPageAction"].addListener(function(pageActionId, + pageActionInfo) { chrome.windows.getCurrent(function(window) { - chrome.tabs.get(reply.data.tabId, function(tab) { + chrome.tabs.get(pageActionInfo.tabId, function(tab) { // We need to know if we are the active window, because the tab may // have moved to another window and we don't want to execute this // action multiple times. @@ -43,7 +44,7 @@ // Create a new tab showing the subscription page with the right // feed URL. chrome.tabs.create({url: "subscribe.html?" + - feedData[reply.data.tabId].feedUrl, + feedData[pageActionInfo.tabId].feedUrl, windowId: window.windowId}); } }); diff --git a/chrome/test/data/extensions/samples/tabs/tabs_api.html b/chrome/test/data/extensions/samples/tabs/tabs_api.html index cc21232..9b9f519 100644 --- a/chrome/test/data/extensions/samples/tabs/tabs_api.html +++ b/chrome/test/data/extensions/samples/tabs/tabs_api.html @@ -24,19 +24,19 @@ function isInt(i) { } function loadWindowList() { - chrome.windows.getAll(true, function(windowList) { + chrome.windows.getAll({ populate: true }, function(windowList) { tabs = {}; tabIds = []; for (var i = 0; i < windowList.length; i++) { windowList[i].current = (windowList[i].id == currentWindowId); windowList[i].focused = (windowList[i].id == focusedWindowId); - + for (var j = 0; j < windowList[i].tabs.length; j++) { tabIds[tabIds.length] = windowList[i].tabs[j].id; tabs[windowList[i].tabs[j].id] = windowList[i].tabs[j]; } - } - + } + var input = new JsExprContext(windowList); var output = document.getElementById('windowList'); jstProcess(input, output); @@ -139,8 +139,8 @@ function clearLog() { document.getElementById('log').innerHTML = ''; } -chrome.windows.onCreated.addListener(function(windowId) { - appendToLog('windows.onCreated -- window: ' + windowId); +chrome.windows.onCreated.addListener(function(createInfo) { + appendToLog('windows.onCreated -- window: ' + createInfo.id); loadWindowList(); }); diff --git a/chrome/test/data/extensions/uitest/event_sink/test.html b/chrome/test/data/extensions/uitest/event_sink/test.html index 5462243..284d8c5 100644 --- a/chrome/test/data/extensions/uitest/event_sink/test.html +++ b/chrome/test/data/extensions/uitest/event_sink/test.html @@ -15,7 +15,7 @@ HOLA!!! If you dont see the message DONE, then there is an error in the script. }); // Window events. - chrome.windows.onCreated.addListener(function(windowId) { + chrome.windows.onCreated.addListener(function(createInfo) { portToAutomation.postMessage(chrome.windows.onCreated.eventName_); }); chrome.windows.onRemoved.addListener(function(windowId) { @@ -49,8 +49,8 @@ HOLA!!! If you dont see the message DONE, then there is an error in the script. }); // Bookmark events. - chrome.bookmarks.onAdded.addListener(function(info) { - portToAutomation.postMessage(chrome.bookmarks.onAdded.eventName_); + chrome.bookmarks.onCreated.addListener(function(info) { + portToAutomation.postMessage(chrome.bookmarks.onCreated.eventName_); }); chrome.bookmarks.onRemoved.addListener(function(info) { portToAutomation.postMessage(chrome.bookmarks.onRemoved.eventName_); @@ -62,7 +62,7 @@ HOLA!!! If you dont see the message DONE, then there is an error in the script. portToAutomation.postMessage(chrome.bookmarks.onMoved.eventName_); }); chrome.bookmarks.onChildrenReordered.addListener(function(bookmarkId, - children) { + reorderInfo) { portToAutomation.postMessage( chrome.bookmarks.onChildrenReordered.eventName_); }); |