summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-22 22:28:45 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-22 22:28:45 +0000
commit03b1575eb9349ad2c7563ea0caef88da0906537e (patch)
tree5bb1bb45fb5cc1cfa185d397d539b637e682d84b /chrome/test
parent9be096ebf44c2d685335bf78ddde018ea4a50cb0 (diff)
downloadchromium_src-03b1575eb9349ad2c7563ea0caef88da0906537e.zip
chromium_src-03b1575eb9349ad2c7563ea0caef88da0906537e.tar.gz
chromium_src-03b1575eb9349ad2c7563ea0caef88da0906537e.tar.bz2
implement remaining tab events (except for onTabUpdated).
Review URL: http://codereview.chromium.org/88053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/test/TabsAPI/1/tabs_api.html73
1 files changed, 72 insertions, 1 deletions
diff --git a/chrome/test/data/extensions/test/TabsAPI/1/tabs_api.html b/chrome/test/data/extensions/test/TabsAPI/1/tabs_api.html
index 8f2c277..a506fd2 100644
--- a/chrome/test/data/extensions/test/TabsAPI/1/tabs_api.html
+++ b/chrome/test/data/extensions/test/TabsAPI/1/tabs_api.html
@@ -84,11 +84,63 @@ function clearLog() {
document.getElementById('log').innerHTML = '';
}
+chromium.tabs.onTabCreated.addListener(function(data) {
+ appendToLog('onTabCreated -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index);
+ loadWindowList();
+});
+
+chromium.tabs.onTabAttached.addListener(function(data) {
+ appendToLog('onTabAttached -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index);
+ loadWindowList();
+});
+
chromium.tabs.onTabMoved.addListener(function(data) {
- appendToLog('onTabMoved: ' + data.tabId + ' from ' + data.fromIndex + ' to ' + data.toIndex);
+ appendToLog('onTabMoved -- window: ' + data.windowId + ' tab: ' + data.tabId + ' from ' + data.fromIndex + ' to ' + data.toIndex);
+ loadWindowList();
+});
+
+chromium.tabs.onTabDetached.addListener(function(data) {
+ appendToLog('onTabDetached -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index);
+ loadWindowList();
+});
+
+chromium.tabs.onTabSelectionChanged.addListener(function(data) {
+ appendToLog('onTabSelectionChanged -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index);
loadWindowList();
});
+chromium.tabs.onTabRemoved.addListener(function(data) {
+ appendToLog('onTabRemoved -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index);
+ loadWindowList();
+});
+
+function isInt(i) {
+ return (typeof i == "number") && !(i % 1) && !isNaN(i);
+}
+
+function createWindow() {
+ var args = {
+ 'left': parseInt(document.getElementById('new_window_left').value),
+ 'top': parseInt(document.getElementById('new_window_top').value),
+ 'width': parseInt(document.getElementById('new_window_width').value),
+ 'height': parseInt(document.getElementById('new_window_height').value),
+ 'url': document.getElementById('new_window_url').value
+ }
+
+ if (!isInt(args.left))
+ delete args.left;
+ if (!isInt(args.top))
+ delete args.top;
+ if (!isInt(args.width))
+ delete args.width;
+ if (!isInt(args.height))
+ delete args.height;
+ if (!args.url)
+ delete args.url;
+
+ chromium.tabs.createWindow(args);
+}
+
</script>
</head>
<body onload="loadWindowList();">
@@ -131,6 +183,24 @@ chromium.tabs.onTabMoved.addListener(function(data) {
</div>
</div>
</div>
+ <div style="background-color: #EEEEBB; margin: 20px; padding: 8px">
+ <h3 style="text-align: center; margin: 8px"> Create Window</h3>
+ <div style="margin: 8px">
+ <div style="width: 300px; display: inline-block">
+ left: <input style="width: 20px" type="text" id="new_window_left" />
+ top: <input style="width: 20px" type="text" id="new_window_top" />
+ width: <input style="width: 20px" type="text" id="new_window_width" />
+ height: <input style="width: 20px" type="text" id="new_window_height" />
+ </div>
+ </div>
+ <div style="margin: 8px">
+ <div>
+ <div style="width: 40px; display:inline-block">url:</div>
+ <input style="width: 90%" type="text" id="new_window_url" />
+ </div>
+ </div>
+ <button onclick="createWindow();">Create</button>
+ </div>
<div style="background-color: #EEEEAA; margin: 20px; padding: 8px">
<h3 style="text-align: center; margin: 8px"> Create Tab</h3>
<div style="margin: 8px">
@@ -158,6 +228,7 @@ chromium.tabs.onTabMoved.addListener(function(data) {
<button onclick="updateAll();">Update All</button>
<button onclick="moveAll();">Move All</button>
<button onclick="clearLog();">-->Clear Log</button>
+ <button onclick="chromium.tabs.createWindow();">New Window</button>
</div>
<div id="log" style="background-color: #EEAAEE; margin: 20px; padding: 8px">
</div>