[bugzilla-gnome-org-extensions] Make sure console.log is always available
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] Make sure console.log is always available
- Date: Thu, 20 Nov 2014 22:19:34 +0000 (UTC)
commit 393281ad34a9f86fdebac6b09245a5129fd8a8de
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Mon Sep 14 18:14:43 2009 -0400
Make sure console.log is always available
flattener.py: Write out a prolog and use it to define console.log if
not otherwise defined.
jstest.c: Set <global objects>.console = <global object>, so that
console.log is defined.
flattener.py | 15 +++++++++++++++
jstest.c | 9 +++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/flattener.py b/flattener.py
index 760fa94..bbeaf85 100755
--- a/flattener.py
+++ b/flattener.py
@@ -33,6 +33,20 @@ class Flattener(object):
self.outf = outf
self.flattened_modules = set()
+ def output_prologue(self):
+ self.outf.write("""\
+// Splinter - patch review add-on for Bugzilla
+// By Owen Taylor <otaylor fishsoup net>
+// Copyright 2009, Red Hat, Inc.
+// Licensed under MPL 1.1 or later, or GPL 2 or later
+// http://git.fishsoup.net/cgit/splinter
+
+if (!console) {
+ var console = {};
+ console.log = function() {};
+}
+""");
+
def flatten(self, filename, namespace=None):
locals = {}
f = open(filename)
@@ -95,5 +109,6 @@ class Flattener(object):
if __name__ == '__main__':
flattener = Flattener(sys.stdout)
+ flattener.output_prologue()
for filename in sys.argv[1:]:
flattener.flatten(filename)
diff --git a/jstest.c b/jstest.c
index 12818fc..2e05562 100644
--- a/jstest.c
+++ b/jstest.c
@@ -395,6 +395,15 @@ int main(int argc, const char *argv[])
if (!JS_DefineFunctions(cx, global, global_functions))
return 1;
+ /* For quick-and-dirty compat with Firebug, the 'console' property
+ * points back to the global object which has 'log'
+ */
+
+ if (!JS_DefineProperty(cx, global, "console",
+ OBJECT_TO_JSVAL(global), NULL, NULL,
+ JSPROP_PERMANENT | JSPROP_READONLY))
+ return FALSE;
+
if (!g_file_get_contents(argv[i], &src, &length, &error)) {
g_printerr("%s\n", error->message);
return 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]