summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 23:01:19 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 23:01:19 +0000
commit4adfcda50f8fb51bc1c29911fc764ab05fa36230 (patch)
treebe5702082d62263cebd12b2c0ff879e2891ec6f2
parent4f552ba2fe6734e252a6ac06f00973f8fa31efb2 (diff)
downloadchromium_src-4adfcda50f8fb51bc1c29911fc764ab05fa36230.zip
chromium_src-4adfcda50f8fb51bc1c29911fc764ab05fa36230.tar.gz
chromium_src-4adfcda50f8fb51bc1c29911fc764ab05fa36230.tar.bz2
test conversion from toolstrips to actions
Review URL: http://codereview.chromium.org/264019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28624 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/test/data/extensions/samples/buildbot/bg.html58
-rwxr-xr-xchrome/test/data/extensions/samples/buildbot/chromium.pngbin0 -> 1736 bytes
-rw-r--r--chrome/test/data/extensions/samples/buildbot/manifest.json13
-rwxr-xr-xchrome/test/data/extensions/samples/buildbot/popup.html147
-rwxr-xr-xchrome/test/data/extensions/samples/mappy/manifest.json12
-rwxr-xr-xchrome/test/data/extensions/samples/mappy/marker.pngbin0 -> 2237 bytes
-rwxr-xr-xchrome/test/data/extensions/samples/mappy/popup.html51
7 files changed, 271 insertions, 10 deletions
diff --git a/chrome/test/data/extensions/samples/buildbot/bg.html b/chrome/test/data/extensions/samples/buildbot/bg.html
new file mode 100755
index 0000000..e69110c
--- /dev/null
+++ b/chrome/test/data/extensions/samples/buildbot/bg.html
@@ -0,0 +1,58 @@
+<script>
+var statusURL = "http://chromium-status.appspot.com/current";
+
+function updateStatus(text) {
+ // Page outputs a line like this:
+ // <div class="Notice">Tree is open (issue -> person) </div>
+ // Although what's in the <div> is arbitrary and typed by a person.
+ var results = (new RegExp('"Notice"[^>]*>(.*)<', 'g')).exec(text);
+ if (!results || results.index < 0) {
+ throw new Error("couldn't find status div in " + text);
+ }
+ var status = results[1];
+ chrome.browserAction.setName(status);
+ var open = /open/i;
+ if (open.exec(status)) {
+ //chrome.browserAction.setBadgeText("\u263A");
+ chrome.browserAction.setBadgeText("\u2022");
+ chrome.browserAction.setBadgeBackgroundColor([255,0,255,0]);
+ } else {
+ //chrome.browserAction.setBadgeText("\u2639");
+ chrome.browserAction.setBadgeText("\u00D7");
+ chrome.browserAction.setBadgeBackgroundColor([255,255,0,0]);
+ }
+}
+
+function requestStatus() {
+ requestURL(statusURL, updateStatus);
+ setTimeout(requestStatus, 30000);
+}
+
+function requestURL(url, callback) {
+ console.log("requestURL: " + url);
+ var xhr = new XMLHttpRequest();
+ try {
+ xhr.onreadystatechange = function(state) {
+ if (xhr.readyState == 4) {
+ var text = xhr.responseText;
+ //console.log(text);
+ callback(text);
+ }
+ }
+
+ xhr.onerror = function(error) {
+ console.log("xhr error: " + JSON.stringify(error));
+ console.dir(error);
+ }
+
+ xhr.open("GET", url, true);
+ xhr.send({});
+ } catch(e) {
+ console.log("exception: " + e);
+ }
+}
+
+window.onload = function() {
+ window.setTimeout(requestStatus, 10);
+}
+</script>
diff --git a/chrome/test/data/extensions/samples/buildbot/chromium.png b/chrome/test/data/extensions/samples/buildbot/chromium.png
new file mode 100755
index 0000000..cc9fb60
--- /dev/null
+++ b/chrome/test/data/extensions/samples/buildbot/chromium.png
Binary files differ
diff --git a/chrome/test/data/extensions/samples/buildbot/manifest.json b/chrome/test/data/extensions/samples/buildbot/manifest.json
index 51277c8..ea764ef 100644
--- a/chrome/test/data/extensions/samples/buildbot/manifest.json
+++ b/chrome/test/data/extensions/samples/buildbot/manifest.json
@@ -1,14 +1,17 @@
{
"name": "Chromium Buildbot Monitor",
- "version": "0.6",
+ "version": "0.7",
"description": "Displays the status of the Chromium buildbot in the extension toolstrip. On hover, expands to give more detail about each bot.",
"icons": { "128": "icon.png" },
- "toolstrips": [
- "buildbot.html"
- ],
+ "background_page": "bg.html",
"permissions": [
"http://build.chromium.org/",
"http://chromium-status.appspot.com/",
"http://chrome-buildbot.corp.google.com/"
- ]
+ ],
+ "browser_action": {
+ "name": "Buildbot status",
+ "icons": ["chromium.png"],
+ "popup": { "path": "popup.html", "height": 200 }
+ }
}
diff --git a/chrome/test/data/extensions/samples/buildbot/popup.html b/chrome/test/data/extensions/samples/buildbot/popup.html
new file mode 100755
index 0000000..415c061
--- /dev/null
+++ b/chrome/test/data/extensions/samples/buildbot/popup.html
@@ -0,0 +1,147 @@
+<script>
+var botRoot = "http://build.chromium.org/buildbot/waterfall";
+//var botRoot = "http://chrome-buildbot.corp.google.com:8010";
+var waterfallURL = botRoot + "/bot_status.json?json=1";
+var botList;
+var checkinResults;
+var bots;
+var failures;
+
+function updateBotList(text) {
+ var results = (new RegExp('(.*)<\/body>', 'g')).exec(text);
+ if (!results || results.index < 0) {
+ console.log("Error: couldn't find bot JSON");
+ console.log(text);
+ return;
+ }
+ var data;
+ try {
+ data = JSON.parse(results[1]);
+ } catch (e) {
+ console.dir(e);
+ console.log(text);
+ return;
+ }
+ if (!data) {
+ throw new Error("JSON parse fail: " + results[1]);
+ }
+ botList = data[0];
+ checkinResults = data[1];
+
+ failures = botList.filter(function(bot) {
+ return (bot.color != "success");
+ });
+ displayFailures();
+}
+
+function displayFailures() {
+ var html = "";
+ if (failures.length == 0) {
+ html = "<a href='" + botroot +
+ "' class='open'>The tree is completely green.</a> (no way!)";
+ } else {
+ html = "<div class='closed'>Failures:</div>";
+ failures.forEach(function(bot, i) {
+ html += "<div class='bot " + bot.color +
+ "' onclick='botClicked(" + i + ")'>" +
+ bot.title + "</div>";
+ });
+ }
+ bots.innerHTML = html;
+}
+
+function botClicked(botIndex) {
+ var bot = failures[botIndex];
+ var url = botRoot + "/waterfall?builder=" + bot.name;
+ window.open(url);
+ window.event.stopPropagation();
+}
+
+function requestURL(url, callback) {
+ console.log("requestURL: " + url);
+ var xhr = new XMLHttpRequest();
+ try {
+ xhr.onreadystatechange = function(state) {
+ if (xhr.readyState == 4) {
+ var text = xhr.responseText;
+ //console.log(text);
+ callback(text);
+ }
+ }
+
+ xhr.onerror = function(error) {
+ console.log("xhr error: " + JSON.stringify(error));
+ console.dir(error);
+ }
+
+ xhr.open("GET", url, true);
+ xhr.send({});
+ } catch(e) {
+ console.log("exception: " + e);
+ }
+}
+window.onload = function() {
+ bots = document.getElementById("bots");
+ bots.innerHTML = "onload";
+ //window.setTimeout(requestUrl(waterfallURL, updateBotList), 10);
+ requestURL(waterfallURL, updateBotList);
+}
+</script>
+<style>
+body {
+ font: menu;
+ width: 200px;
+ background-color: #dddddd;
+ overflow: hidden;
+}
+
+.bot {
+ cursor: pointer;
+ -webkit-border-radius: 5px;
+ margin-top: 1px;
+ padding: 3px;
+}
+
+.bot:hover {
+ border: 2px solid black;
+ padding: 2px;
+}
+
+.open {
+ color: green;
+}
+
+.closed {
+ color: red;
+}
+
+.running {
+ background-color: rgb(255, 252, 108);
+ border: 1px solid rgb(197, 197, 109);
+}
+
+.notstarted {
+ border: 1px solid rgb(170, 170, 170);
+}
+
+.failure {
+ background-color: rgb(233, 128, 128);
+ border: 1px solid rgb(167, 114, 114);
+}
+
+.warnings {
+ background-color: rgb(255, 195, 67);
+ border: 1px solid rgb(194, 157, 70);
+}
+
+.success {
+ background-color: rgb(143, 223, 95);
+ border: 1px solid rgb(79, 133, 48);
+}
+
+.exception {
+ background-color: rgb(224, 176, 255);
+ border: 1px solid rgb(172, 160, 179);
+}
+</style>
+<div id="bots">Loading....</div>
diff --git a/chrome/test/data/extensions/samples/mappy/manifest.json b/chrome/test/data/extensions/samples/mappy/manifest.json
index 9deee91..dbcfe06 100755
--- a/chrome/test/data/extensions/samples/mappy/manifest.json
+++ b/chrome/test/data/extensions/samples/mappy/manifest.json
@@ -1,16 +1,18 @@
{
"name": "Mappy",
- "version": "0.4.1",
+ "version": "0.6",
"description": "Finds addresses in the web page you're on and pops up a map window.",
"icons": { "128": "icon.png" },
- "toolstrips": [
- "mappy_toolstrip.html"
- ],
"content_scripts": [
{ "matches": ["http://*/*"], "js": ["mappy_content_script.js"] }
],
"permissions": [
"tabs",
"http://maps.google.com/*"
- ]
+ ],
+ "browser_action": {
+ "name": "Display Map",
+ "icons": ["marker.png"],
+ "popup": { "path": "popup.html", "height": 512 }
+ }
}
diff --git a/chrome/test/data/extensions/samples/mappy/marker.png b/chrome/test/data/extensions/samples/mappy/marker.png
new file mode 100755
index 0000000..aa45f4d
--- /dev/null
+++ b/chrome/test/data/extensions/samples/mappy/marker.png
Binary files differ
diff --git a/chrome/test/data/extensions/samples/mappy/popup.html b/chrome/test/data/extensions/samples/mappy/popup.html
new file mode 100755
index 0000000..409b216
--- /dev/null
+++ b/chrome/test/data/extensions/samples/mappy/popup.html
@@ -0,0 +1,51 @@
+<head>
+<style>
+body {
+ margin: 0px;
+ padding: 0px;
+}
+#map {
+ width: 512px;
+ height: 512px;
+}
+</style>
+<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w&sensor=false"
+ type="text/javascript"></script>
+<script>
+var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w";
+
+function gclient_geocode(address) {
+ var geocoder = new GClientGeocoder();
+ geocoder.getLatLng(address, function(point) {
+ if (!point) {
+ console.log(address + " not found");
+ } else {
+ var latlng = point.toUrlValue();
+ var url = "http://maps.google.com/staticmap?center=" + latlng +
+ "&markers=" + latlng + "&zoom=14" +
+ "&size=512x512&sensor=false&key=" + maps_key;
+ var map = document.getElementById("map");
+ map.src = url;
+ }
+ });
+}
+
+function map() {
+ chrome.tabs.getSelected(null, function(tab) {
+ var port = chrome.tabs.connect(tab.id);
+ if (!port) {
+ console.log("no port");
+ } else {
+ port.onMessage.addListener(function(data) {
+ var address = data.values[0];
+ gclient_geocode(address);
+ });
+ port.postMessage({message: "hello tab: " + tab.id});
+ }
+ });
+};
+</script>
+</head>
+<body onload="map()">
+<img id="map" onclick="window.close()">
+</body>