Index: chrome/test/data/extensions/samples/test_page_action/background.html |
diff --git a/chrome/test/data/extensions/samples/test_page_action/background.html b/chrome/test/data/extensions/samples/test_page_action/background.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2c5685de9fcd2986b117c59fcec78eb4460d22ea |
--- /dev/null |
+++ b/chrome/test/data/extensions/samples/test_page_action/background.html |
@@ -0,0 +1,65 @@ |
+<html> |
+<head> |
+<script> |
+ var lastTabId = 0; |
+ chrome.tabs.onUpdated.addListener(function(tabId, p) { |
+ lastTabId = tabId; |
+ }); |
+ |
+ // Called when the user clicks on the browser action. |
+ var clicks = 0; |
+ chrome.pageAction.onClicked.addListener(function(_, info) { |
+ chrome.pageAction.setIcon({iconIndex: clicks, tabId: info.tabId}); |
+ if (clicks % 2) { |
+ chrome.pageAction.show(info.tabId); |
+ } else { |
+ chrome.pageAction.hide(info.tabId); |
+ setTimeout(function() { chrome.pageAction.show(info.tabId); }, 1000); |
+ } |
+ chrome.pageAction.setTitle({title: "click:" + clicks, tabId: info.tabId}); |
+ chrome.pageAction.setBadgeTextColor({ |
+ tabId: info.tabId, |
+ color: [0, 255, clicks * 50, 255] |
+ }); |
+ chrome.pageAction.setBadgeBackgroundColor({ |
+ tabId: info.tabId, |
+ color: [255, clicks * 50, 0, 255] |
+ }); |
+ chrome.pageAction.setBadgeText({ |
+ tabId: info.tabId, |
+ text: clicks + "" |
+ }); |
+ |
+ // We only have 2 icons, but cycle through 3 icons to test the |
+ // out-of-bounds index bug. |
+ clicks++; |
+ if (clicks > 3) |
+ clicks = 0; |
+ }); |
+ var i = 0; |
+ |
+ window.setInterval(function() { |
+ // Don't animate while in "click" mode. |
+ if (clicks > 0) return; |
+ i++; |
+ chrome.pageAction.setIcon({imageData: draw(i*2, i*4), tabId: lastTabId}); |
+ }, 50); |
+ |
+ function draw(starty, startx) { |
+ var canvas = document.getElementById('canvas'); |
+ var context = canvas.getContext('2d'); |
+ context.clearRect(0, 0, canvas.width, canvas.height); |
+ context.fillStyle = "rgba(0,200,0,255)"; |
+ context.fillRect(startx % 19, starty % 19, 8, 8); |
+ context.fillStyle = "rgba(0,0,200,255)"; |
+ context.fillRect((startx + 5) % 19, (starty + 5) % 19, 8, 8); |
+ context.fillStyle = "rgba(200,0,0,255)"; |
+ context.fillRect((startx + 10) % 19, (starty + 10) % 19, 8, 8); |
+ return context.getImageData(0, 0, 19, 19); |
+ } |
+</script> |
+</head> |
+<body> |
+<canvas id="canvas" width="19" height="19"></canvas> |
+</body> |
+</html> |