You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/05/23 22:03:25 UTC
[02/30] git commit: Firebug integration.
Firebug integration.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/7d0e7174
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/7d0e7174
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/7d0e7174
Branch: refs/heads/master
Commit: 7d0e71748fefffaf5c50e7b3ea3b1d270bc87268
Parents: 28404d5
Author: Shravan Narayan <sh...@google.com>
Authored: Wed May 1 22:11:28 2013 -0400
Committer: Shravan Narayan <sh...@google.com>
Committed: Thu May 2 00:29:47 2013 -0400
----------------------------------------------------------------------
www/contextMenu.html | 3 ++
www/js/ContextMenu.js | 47 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/7d0e7174/www/contextMenu.html
----------------------------------------------------------------------
diff --git a/www/contextMenu.html b/www/contextMenu.html
index 3f30fd3..c1e04fc 100644
--- a/www/contextMenu.html
+++ b/www/contextMenu.html
@@ -44,6 +44,9 @@
<a href="app-bundle:///index.html#/?lastLaunched=true"><button>Restart</button></a>
</li>
<li>
+ <button id="__cordovaappharness_contextMenu_firebug_button">Firebug</button>
+ </li>
+ <li>
<a href="app-bundle:///index.html"><button>Back to Main Menu</button></a>
</li>
</ul>
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/7d0e7174/www/js/ContextMenu.js
----------------------------------------------------------------------
diff --git a/www/js/ContextMenu.js b/www/js/ContextMenu.js
index 3e64487..16d6f08 100644
--- a/www/js/ContextMenu.js
+++ b/www/js/ContextMenu.js
@@ -14,6 +14,9 @@
// retrieve the context menu
xhr.open("GET", contextHTMLUrl, true);
xhr.send();
+
+ loadFirebug(false);
+ attachErrorListener();
}
function onInject(stringifiedHtml) {
@@ -21,6 +24,8 @@
document.body.innerHTML += stringifiedHtml;
var contextDiv = "__cordovaappharness_contextMenu_div";
+ var showFirebugButton = "__cordovaappharness_contextMenu_firebug_button";
+
// Setup the listeners to toggle the context menu
document.addEventListener("touchmove", function (event) {
if(event.touches.length >= 3) {
@@ -31,6 +36,48 @@
document.getElementById(contextDiv).onclick = function() {
document.getElementById(contextDiv).style.display = "none";
};
+
+ var firstTime = true;
+ document.getElementById(showFirebugButton).onclick = function(){
+ try {
+ if(firstTime){
+ console.warn("Note that messages logged to the console at the app startup may not be visible here.");
+ console.warn("Do not use the close button on Firebug. Your console logs will be cleared. Use minimize instead.");
+ firstTime = false;
+ }
+ window.Firebug.chrome.open();
+ } catch(e) {
+ // hack - FirebugLite appears to have several bugs. One of which is - open firebug, user shuts down FirebugLite through the UI.
+ // FirebugLite is now in a bad state of neither being usable or removable. Any calls to open throw an error.
+ // The following lines removes the flags that FirebugLite looks for manually and makes it think it has not loaded it yet
+ // Then FirebugLite is loaded into the page again
+ // This hack should be revisited when FirebugLite moves from version 1.4
+ // Either the hack won't be needed anymore or the hack should be checked too see if it still works.
+ var el = document.getElementById("FirebugLite");
+ if(el) {
+ el.setAttribute("id", "");
+ }
+ delete console.firebuglite;
+ loadFirebug(true);
+ }
+ };
+ }
+
+ function loadFirebug(startOpened){
+ var el = document.createElement("script");
+ el.setAttribute("id", "FirebugLite");
+ el.setAttribute("src", "https://getfirebug.com/firebug-lite.js");
+ el.setAttribute("FirebugLite", "4");
+ el.innerHTML = el.innerHTML = "{ debug : false, startOpened : " + startOpened + ", showIconWhenHidden : false, saveCommandLineHistory : true, saveCookies : false }";
+ document.head.appendChild(el);
+ console.log("test");
+ }
+
+ // FirebugLite doesn't catch errors from window.onerror like desktop browser's dev tools do. So we add it manually.
+ function attachErrorListener(){
+ window.onerror = function(msg, url, line) {
+ console.error("Error: " + msg + " on line: " + line + " in file: " + url);
+ };
}
initialise();