mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1033927 - Drop support for custom [object XrayWrapper [object ClassName]] stringification. r=peterv
This commit is contained in:
parent
acae1e61fc
commit
b3a9b29482
@ -1598,8 +1598,7 @@ ConcatJSString(JSContext* cx, const char* pre, JS::Handle<JSString*> str, const
|
||||
|
||||
bool
|
||||
NativeToString(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj, const char* pre,
|
||||
const char* post,
|
||||
JS::Handle<JSObject*> obj,
|
||||
JS::MutableHandle<JS::Value> v)
|
||||
{
|
||||
JS::Rooted<JSPropertyDescriptor> toStringDesc(cx);
|
||||
@ -1644,7 +1643,6 @@ NativeToString(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Rooted<JSFunction*> fun(cx, JS_GetObjectFunction(obj));
|
||||
str = JS_DecompileFunction(cx, fun, 0);
|
||||
}
|
||||
str = ConcatJSString(cx, pre, str, post);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2385,14 +2385,11 @@ MustInheritFromNonRefcountedDOMObject(NonRefcountedDOMObject*)
|
||||
* wrapper is the Xray JS object.
|
||||
* obj is the target object of the Xray, a binding's instance object or a
|
||||
* interface or interface prototype object.
|
||||
* pre is a string that should be prefixed to the value.
|
||||
* post is a string that should be prefixed to the value.
|
||||
* v contains the JSString for the value if the function returns true.
|
||||
*/
|
||||
bool
|
||||
NativeToString(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj, const char* pre,
|
||||
const char* post,
|
||||
JS::Handle<JSObject*> obj,
|
||||
JS::MutableHandle<JS::Value> v);
|
||||
|
||||
HAS_MEMBER(JSBindingFinalized)
|
||||
|
@ -34,7 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
|
||||
|
||||
try {
|
||||
var css = Components.utils.evalInSandbox("CSSStyleDeclaration", sandbox);
|
||||
is(css.prototype, "[object XrayWrapper [object CSSStyleDeclarationPrototype]]", "'CSSStyleDeclaration.prototype' in a sandbox should return the CSSStyleDeclaration interface prototype object");
|
||||
is(css.prototype, "[object CSSStyleDeclarationPrototype]", "'CSSStyleDeclaration.prototype' in a sandbox should return the CSSStyleDeclaration interface prototype object");
|
||||
} catch (e) {
|
||||
ok(false, "'CSSStyleDeclaration' shouldn't throw in a sandbox");
|
||||
}
|
||||
@ -94,7 +94,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
|
||||
}
|
||||
try {
|
||||
var xhr = Components.utils.evalInSandbox("XMLHttpRequest", sandbox);
|
||||
is(xhr, "[object XrayWrapper " + XMLHttpRequest + "]", "'XMLHttpRequest' in a sandbox should return the XMLHttpRequest interface object");
|
||||
is(xhr, XMLHttpRequest + "", "'XMLHttpRequest' in a sandbox should return the XMLHttpRequest interface object");
|
||||
ok(isXrayWrapper(xhr.prototype), "Getting the prototype property on an Xray wrapper of an interface object should return an Xray wrapper");
|
||||
isnot(Object.getOwnPropertyDescriptor(xhr, "UNSENT"), undefined,
|
||||
"We should claim to have an UNSENT constant");
|
||||
@ -109,13 +109,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
|
||||
}
|
||||
try {
|
||||
var xhr = Components.utils.evalInSandbox("new XMLHttpRequest()", sandbox);
|
||||
is("" + xhr, "[object XrayWrapper " + new XMLHttpRequest() + "]", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
|
||||
is("" + xhr, new XMLHttpRequest() + "", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
|
||||
} catch (e) {
|
||||
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox (1)");
|
||||
}
|
||||
try {
|
||||
var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype.toString = function () { return 'Failed'; }; new XMLHttpRequest();", sandbox);
|
||||
is(xhr.toString(), "[object XrayWrapper " + new XMLHttpRequest() + "]", "XMLHttpRequest.prototype.toString in the sandbox should not override the native toString behaviour");
|
||||
is(xhr.toString(), new XMLHttpRequest() + "", "XMLHttpRequest.prototype.toString in the sandbox should not override the native toString behaviour");
|
||||
} catch (e) {
|
||||
ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox (2)");
|
||||
}
|
||||
@ -141,7 +141,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=741267
|
||||
Components.utils.evalInSandbox("document.defaultView.XMLHttpRequest = function() {};", sandbox);
|
||||
var win = Components.utils.evalInSandbox("document.defaultView", sandbox);
|
||||
var xhr = new win.XMLHttpRequest();
|
||||
is("" + xhr, "[object XrayWrapper " + new XMLHttpRequest() + "]", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
|
||||
is("" + xhr, new XMLHttpRequest() + "", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
|
||||
} catch (e) {
|
||||
ok(false, "'XMLHttpRequest()' shouldn't throw in a sandbox");
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
is(list.item, list.item, "don't recreate functions for each get");
|
||||
|
||||
var list2 = list[2];
|
||||
ok(list[2].toString().indexOf("[object HTMLParagraphElement"), "list[2] exists");
|
||||
ok(list[2].toString().indexOf("[object HTMLParagraphElement") >= 0, "list[2] exists");
|
||||
ok("2" in list, "in operator works");
|
||||
|
||||
is(win.document.body.removeChild(win.document.body.lastChild), list2, "remove last paragraph element");
|
||||
|
8
js/xpconnect/tests/unit/test_bug1033927.js
Normal file
8
js/xpconnect/tests/unit/test_bug1033927.js
Normal file
@ -0,0 +1,8 @@
|
||||
const Cu = Components.utils;
|
||||
function run_test() {
|
||||
var sb = Cu.Sandbox('http://www.example.com', { wantGlobalProperties: ['XMLHttpRequest']});
|
||||
var xhr = Cu.evalInSandbox('new XMLHttpRequest()', sb);
|
||||
do_check_eq(xhr.toString(), '[object XMLHttpRequest]');
|
||||
do_check_eq((new sb.Object()).toString(), '[object Object]');
|
||||
do_check_eq((new sb.Uint16Array()).toString(), '[object Uint16Array]');
|
||||
}
|
@ -45,6 +45,7 @@ support-files =
|
||||
[test_bug1021312.js]
|
||||
[test_bug1033253.js]
|
||||
[test_bug1033920.js]
|
||||
[test_bug1033927.js]
|
||||
[test_bug_442086.js]
|
||||
[test_file.js]
|
||||
[test_blob.js]
|
||||
|
@ -2100,11 +2100,11 @@ XrayToString(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
RootedObject obj(cx, XrayTraits::getTargetObject(wrapper));
|
||||
|
||||
if (UseDOMXray(obj))
|
||||
return NativeToString(cx, wrapper, obj, args.rval());
|
||||
|
||||
static const char start[] = "[object XrayWrapper ";
|
||||
static const char end[] = "]";
|
||||
if (UseDOMXray(obj))
|
||||
return NativeToString(cx, wrapper, obj, start, end, args.rval());
|
||||
|
||||
nsAutoString result;
|
||||
result.AppendASCII(start);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user