changeset 11:bde6607a3620

changed TCB/sample module code a bit.
author Atul Varma <varmaa@toolness.com>
date Fri, 19 Jun 2009 15:07:12 -0700
parents 16a605ff036c
children e14f433f3a58
files sample-module.js tcb.js
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sample-module.js	Fri Jun 19 14:44:39 2009 -0700
+++ b/sample-module.js	Fri Jun 19 15:07:12 2009 -0700
@@ -1,3 +1,7 @@
+function boo() {
+  return boo.caller;
+}
+
 exports.foo = function foo() {
-  return imports.blop + " "  + foo.caller;
+  return imports.blop + " "  + foo.caller + " " + boo();
 };
--- a/tcb.js	Fri Jun 19 14:44:39 2009 -0700
+++ b/tcb.js	Fri Jun 19 15:07:12 2009 -0700
@@ -1,9 +1,13 @@
 // This security function is called by the platform whenever a
 // particular property needs to be accessed on a particular object.
 function checkAccess(obj, id) {
-  var frame = stack();
-  if (frame.filename != "tcb.js")
-    print("access request from " + frame.filename);
+  var frame = stack().caller;
+  if (!(frame.filename == null ||
+        frame.filename == "tcb.js"))
+    print("access request from " + frame.filename + " on property '" + id +
+          "' of " + obj);
+  // TODO: this won't work for the 'caller' property, looks like we need
+  // to look it up ourselves.
   return lookupProperty(obj, id);
 }