Closed Bug 390946 Opened 17 years ago Closed 17 years ago

XOW toString value horks several js browser tests

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: bc, Assigned: mrbkap)

References

()

Details

(Keywords: regression)

Attachments

(2 files)

ecma_2/Statements/forin-002.js
ecma_3/Object/class-001.js

fail in the browser since the String value of a XOW now shows the wrapper and not the underlying object.
Flags: in-testsuite+
Attached patch Fix (deleted) — Splinter Review
The problem here was that eval was wrapping too many things. I also changed things so that the function wrapper for eval is constant, allowing window.eval === window.eval.
Attachment #275858 - Flags: superreview?(jst)
Attachment #275858 - Flags: review?(jst)
(In reply to comment #1)
> I also changed things so that the function wrapper for eval is constant,
> allowing window.eval === window.eval.

Note: this should have a test somewhere.
It's covered by one of the broken tests here (that's how I knew that I had to do this).
Status: NEW → ASSIGNED
Comment on attachment 275858 [details] [diff] [review]
Fix

- In WrapSameOriginProp():

+  JSObject *wrappedObj = JSVAL_TO_OBJECT(*vp);
+  if (JS_ObjectIsFunction(cx, wrappedObj) &&
+      JS_GetFunctionNative(cx, reinterpret_cast<JSFunction *>
+                                               (JS_GetPrivate(cx, wrappedObj))) ==
+      XPCWrapper::sEvalNative) {
+    return XPC_XOW_WrapFunction(cx, outerObj, wrappedObj, vp);
+  }
+
+  const char *name = JS_GET_CLASS(cx, wrappedObj)->name;
+  if (XPC_XOW_ClassNeedsXOW(name)) {
+    return XPC_XOW_WrapObject(cx, GetGlobalObject(cx, outerObj), vp);
+  }

Might be faster if you reorder this code to do the XPC_XOW_ClassNeedsXOW() call before the function fu, as window objects etc are probably more common here than functions. Either way works tho...

- In XPCWrapper::NewResolve():

+  // Hack alert: we only do this for same-origin calls on XOWs: we want
+  // to preserve 'eval' on the wrapper itself since that code needs
+  // eval to be wrapped.

Um, what code needs eval to be wrapped? :)

r+sr=jst
Attachment #275858 - Flags: superreview?(jst)
Attachment #275858 - Flags: superreview+
Attachment #275858 - Flags: review?(jst)
Attachment #275858 - Flags: review+
Attachment #275858 - Flags: approval1.9+
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Attached patch As checked in (deleted) — Splinter Review
<http://test.bclary.com/tests/mozilla.org/js/js-test-driver-standards.html?test=ecma_3/Object/class-001.js;language=type;text/javascript> still fails with 

FAILED! expected: [reported from test()] Expected value 'Window', Actual value 'XPCCrossOriginWrapper' 
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
The test explicitly calls Object.prototype.toString.call(window). I can't really fix that.
In fact, I don't want to fix that. Bob, can you change the test to use |this + ''| or something? Marking this as fixed again.
Status: REOPENED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
The test is explicitly calling Object.prototype.toString. Changing that would affect the other types where the default toString would differ. How about I check for the wrapper and just skip it ala

--- ecma_3/Object/class-001.js  26 May 2007 00:19:30 -0000      1.6
+++ ecma_3/Object/class-001.js  5 Oct 2007 20:34:47 -0000
@@ -59,7 +59,14 @@
 status = 'the global object';
 actual = getJSClass(this);
 expect = GLOBAL;
-addThis();
+if (expect == 'Window' && actual == 'XPCCrossOriginWrapper')
+{
+  print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946');
+}
+else
+{
+  addThis();
+}
That seems fair to me.
done deal.
/cvsroot/mozilla/js/tests/ecma_3/Object/class-001.js,v  <--  class-001.js
new revision: 1.7; previous revision: 1.6
verified fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: