mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 942251: Rename Debugger.Script.prototype.elementProperty to elementAttributeName, and all related. r=sfink
--HG-- rename : js/src/jit-test/tests/debug/Source-elementProperty.js => js/src/jit-test/tests/debug/Source-elementAttributeName.js
This commit is contained in:
parent
84f1ffacbe
commit
6677bbefbc
@ -11,7 +11,7 @@ var element = {};
|
||||
offThreadCompileScript('Error()', { element: element }); // shouldn't crash
|
||||
runOffThreadScript();
|
||||
|
||||
var elementAttribute = "molybdenum";
|
||||
elementAttribute += elementAttribute + elementAttribute + elementAttribute;
|
||||
offThreadCompileScript('Error()', { elementProperty: elementAttribute }); // shouldn't crash
|
||||
var elementAttributeName = "molybdenum";
|
||||
elementAttributeName += elementAttributeName + elementAttributeName + elementAttributeName;
|
||||
offThreadCompileScript('Error()', { elementAttributeName: elementAttributeName }); // shouldn't crash
|
||||
runOffThreadScript();
|
||||
|
11
js/src/jit-test/tests/debug/Source-elementAttributeName.js
Normal file
11
js/src/jit-test/tests/debug/Source-elementAttributeName.js
Normal file
@ -0,0 +1,11 @@
|
||||
// Source.prototype.elementAttributeName can be a string or undefined.
|
||||
|
||||
var g = newGlobal('new-compartment');
|
||||
var dbg = new Debugger;
|
||||
var gw = dbg.addDebuggee(g);
|
||||
g.evaluate("function f(x) { return 2*x; }", {elementAttributeName: "src"});
|
||||
var fw = gw.getOwnPropertyDescriptor('f').value;
|
||||
assertEq(fw.script.source.elementAttributeName, "src");
|
||||
g.evaluate("function f(x) { return 2*x; }");
|
||||
var fw = gw.getOwnPropertyDescriptor('f').value;
|
||||
assertEq(fw.script.source.elementAttributeName, undefined);
|
@ -1,11 +0,0 @@
|
||||
// Source.prototype.elementProperty can be a string or undefined.
|
||||
|
||||
var g = newGlobal('new-compartment');
|
||||
var dbg = new Debugger;
|
||||
var gw = dbg.addDebuggee(g);
|
||||
g.evaluate("function f(x) { return 2*x; }", {elementProperty: "src"});
|
||||
var fw = gw.getOwnPropertyDescriptor('f').value;
|
||||
assertEq(fw.script.source.elementProperty, "src");
|
||||
g.evaluate("function f(x) { return 2*x; }");
|
||||
var fw = gw.getOwnPropertyDescriptor('f').value;
|
||||
assertEq(fw.script.source.elementProperty, undefined);
|
@ -23,11 +23,11 @@ assertThrowsInstanceOf(function () {
|
||||
}, TypeError);
|
||||
|
||||
assertThrowsInstanceOf(function () {
|
||||
Debugger.Source.prototype.elementProperty.call(42)
|
||||
Debugger.Source.prototype.elementAttributeName.call(42)
|
||||
}, TypeError);
|
||||
assertThrowsInstanceOf(function () {
|
||||
Debugger.Source.prototype.elementProperty.call({})
|
||||
Debugger.Source.prototype.elementAttributeName.call({})
|
||||
}, TypeError);
|
||||
assertThrowsInstanceOf(function () {
|
||||
Debugger.Source.prototype.elementProperty.call(Debugger.Source.prototype)
|
||||
Debugger.Source.prototype.elementAttributeName.call(Debugger.Source.prototype)
|
||||
}, TypeError);
|
||||
|
@ -4309,7 +4309,7 @@ JS::OwningCompileOptions::OwningCompileOptions(JSContext *cx)
|
||||
: ReadOnlyCompileOptions(),
|
||||
runtime(GetRuntime(cx)),
|
||||
elementRoot(cx),
|
||||
elementPropertyRoot(cx)
|
||||
elementAttributeNameRoot(cx)
|
||||
{
|
||||
}
|
||||
|
||||
@ -4387,15 +4387,15 @@ JS::OwningCompileOptions::wrap(JSContext *cx, JSCompartment *compartment)
|
||||
{
|
||||
if (!compartment->wrap(cx, &elementRoot))
|
||||
return false;
|
||||
if (elementPropertyRoot) {
|
||||
if (!compartment->wrap(cx, elementPropertyRoot.address()))
|
||||
if (elementAttributeNameRoot) {
|
||||
if (!compartment->wrap(cx, elementAttributeNameRoot.address()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version)
|
||||
: ReadOnlyCompileOptions(), elementRoot(cx), elementPropertyRoot(cx)
|
||||
: ReadOnlyCompileOptions(), elementRoot(cx), elementAttributeNameRoot(cx)
|
||||
{
|
||||
this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion();
|
||||
|
||||
@ -4412,8 +4412,8 @@ JS::CompileOptions::wrap(JSContext *cx, JSCompartment *compartment)
|
||||
{
|
||||
if (!compartment->wrap(cx, &elementRoot))
|
||||
return false;
|
||||
if (elementPropertyRoot) {
|
||||
if (!compartment->wrap(cx, elementPropertyRoot.address()))
|
||||
if (elementAttributeNameRoot) {
|
||||
if (!compartment->wrap(cx, elementAttributeNameRoot.address()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -3482,7 +3482,7 @@ class JS_FRIEND_API(ReadOnlyCompileOptions)
|
||||
const char *filename() const { return filename_; }
|
||||
const jschar *sourceMapURL() const { return sourceMapURL_; }
|
||||
virtual JSObject *element() const = 0;
|
||||
virtual JSString *elementProperty() const = 0;
|
||||
virtual JSString *elementAttributeName() const = 0;
|
||||
|
||||
// POD options.
|
||||
JSVersion version;
|
||||
@ -3532,7 +3532,7 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
|
||||
{
|
||||
JSRuntime *runtime;
|
||||
PersistentRootedObject elementRoot;
|
||||
PersistentRootedString elementPropertyRoot;
|
||||
PersistentRootedString elementAttributeNameRoot;
|
||||
|
||||
public:
|
||||
// A minimal constructor, for use with OwningCompileOptions::copy. This
|
||||
@ -3543,7 +3543,7 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
|
||||
~OwningCompileOptions();
|
||||
|
||||
JSObject *element() const MOZ_OVERRIDE { return elementRoot; }
|
||||
JSString *elementProperty() const MOZ_OVERRIDE { return elementPropertyRoot; }
|
||||
JSString *elementAttributeName() const MOZ_OVERRIDE { return elementAttributeNameRoot; }
|
||||
|
||||
// Set this to a copy of |rhs|. Return false on OOM.
|
||||
bool copy(JSContext *cx, const ReadOnlyCompileOptions &rhs);
|
||||
@ -3555,8 +3555,14 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
|
||||
|
||||
/* These setters are infallible, and can be chained. */
|
||||
OwningCompileOptions &setLine(unsigned l) { lineno = l; return *this; }
|
||||
OwningCompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; }
|
||||
OwningCompileOptions &setElementProperty(JSString *p) { elementPropertyRoot = p; return *this; }
|
||||
OwningCompileOptions &setElement(JSObject *e) {
|
||||
elementRoot = e;
|
||||
return *this;
|
||||
}
|
||||
OwningCompileOptions &setElementAttributeName(JSString *p) {
|
||||
elementAttributeNameRoot = p;
|
||||
return *this;
|
||||
}
|
||||
OwningCompileOptions &setPrincipals(JSPrincipals *p) {
|
||||
if (p) JS_HoldPrincipals(p);
|
||||
if (principals_) JS_DropPrincipals(runtime, principals_);
|
||||
@ -3596,12 +3602,12 @@ class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions
|
||||
class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) : public ReadOnlyCompileOptions
|
||||
{
|
||||
RootedObject elementRoot;
|
||||
RootedString elementPropertyRoot;
|
||||
RootedString elementAttributeNameRoot;
|
||||
|
||||
public:
|
||||
explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN);
|
||||
CompileOptions(js::ContextFriendFields *cx, const ReadOnlyCompileOptions &rhs)
|
||||
: ReadOnlyCompileOptions(), elementRoot(cx), elementPropertyRoot(cx)
|
||||
: ReadOnlyCompileOptions(), elementRoot(cx), elementAttributeNameRoot(cx)
|
||||
{
|
||||
copyPODOptions(rhs);
|
||||
|
||||
@ -3610,11 +3616,11 @@ class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) : public ReadOnlyCompileOpti
|
||||
filename_ = rhs.filename();
|
||||
sourceMapURL_ = rhs.sourceMapURL();
|
||||
elementRoot = rhs.element();
|
||||
elementPropertyRoot = rhs.elementProperty();
|
||||
elementAttributeNameRoot = rhs.elementAttributeName();
|
||||
}
|
||||
|
||||
JSObject *element() const MOZ_OVERRIDE { return elementRoot; }
|
||||
JSString *elementProperty() const MOZ_OVERRIDE { return elementPropertyRoot; }
|
||||
JSString *elementAttributeName() const MOZ_OVERRIDE { return elementAttributeNameRoot; }
|
||||
|
||||
CompileOptions &setFile(const char *f) { filename_ = f; return *this; }
|
||||
CompileOptions &setLine(unsigned l) { lineno = l; return *this; }
|
||||
@ -3623,8 +3629,14 @@ class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) : public ReadOnlyCompileOpti
|
||||
}
|
||||
CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL_ = s; return *this; }
|
||||
CompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; }
|
||||
CompileOptions &setElementProperty(JSString *p) { elementPropertyRoot = p; return *this; }
|
||||
CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; }
|
||||
CompileOptions &setElementAttributeName(JSString *p) {
|
||||
elementAttributeNameRoot = p;
|
||||
return *this;
|
||||
}
|
||||
CompileOptions &setPrincipals(JSPrincipals *p) {
|
||||
principals_ = p;
|
||||
return *this;
|
||||
}
|
||||
CompileOptions &setOriginPrincipals(JSPrincipals *p) {
|
||||
originPrincipals_ = p;
|
||||
return *this;
|
||||
|
@ -574,7 +574,7 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
/*
|
||||
* We use this CompileOptions only to initialize the
|
||||
* ScriptSourceObject. Most CompileOptions fields aren't used by
|
||||
* ScriptSourceObject, and those that are (element; elementProperty)
|
||||
* ScriptSourceObject, and those that are (element; elementAttributeName)
|
||||
* aren't preserved by XDR. So this can be simple.
|
||||
*/
|
||||
CompileOptions options(cx);
|
||||
@ -998,7 +998,7 @@ ScriptSourceObject::initElement(HandleObject element)
|
||||
}
|
||||
|
||||
const Value &
|
||||
ScriptSourceObject::elementProperty() const
|
||||
ScriptSourceObject::elementAttributeName() const
|
||||
{
|
||||
const Value &prop = getReservedSlot(ELEMENT_PROPERTY_SLOT);
|
||||
JS_ASSERT(prop.isUndefined() || prop.isString());
|
||||
@ -1038,8 +1038,8 @@ ScriptSourceObject::create(ExclusiveContext *cx, ScriptSource *source,
|
||||
source->incref();
|
||||
sourceObject->initSlot(SOURCE_SLOT, PrivateValue(source));
|
||||
sourceObject->initSlot(ELEMENT_SLOT, ObjectOrNullValue(options.element()));
|
||||
if (options.elementProperty())
|
||||
sourceObject->initSlot(ELEMENT_PROPERTY_SLOT, StringValue(options.elementProperty()));
|
||||
if (options.elementAttributeName())
|
||||
sourceObject->initSlot(ELEMENT_PROPERTY_SLOT, StringValue(options.elementAttributeName()));
|
||||
else
|
||||
sourceObject->initSlot(ELEMENT_PROPERTY_SLOT, UndefinedValue());
|
||||
|
||||
|
@ -498,8 +498,7 @@ class ScriptSourceObject : public JSObject
|
||||
|
||||
JSObject *element() const;
|
||||
void initElement(HandleObject element);
|
||||
|
||||
const Value &elementProperty() const;
|
||||
const Value &elementAttributeName() const;
|
||||
|
||||
private:
|
||||
static const uint32_t SOURCE_SLOT = 0;
|
||||
|
@ -804,13 +804,13 @@ ParseCompileOptions(JSContext *cx, CompileOptions &options, HandleObject opts,
|
||||
if (v.isObject())
|
||||
options.setElement(&v.toObject());
|
||||
|
||||
if (!JS_GetProperty(cx, opts, "elementProperty", &v))
|
||||
if (!JS_GetProperty(cx, opts, "elementAttributeName", &v))
|
||||
return false;
|
||||
if (!v.isUndefined()) {
|
||||
s = ToString(cx, v);
|
||||
if (!s)
|
||||
return false;
|
||||
options.setElementProperty(s);
|
||||
options.setElementAttributeName(s);
|
||||
}
|
||||
|
||||
if (!JS_GetProperty(cx, opts, "lineNumber", &v))
|
||||
@ -4068,9 +4068,9 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
|
||||
" mark the source as being attached to the DOM element |o|. If the\n"
|
||||
" property is omitted or |v| is null, don't attribute the source to\n"
|
||||
" any DOM element.\n"
|
||||
" elementProperty: if present and not undefined, the name of property\n"
|
||||
" of 'element' that holds this code. This is what Debugger.Source\n"
|
||||
" .prototype.elementProperty returns.\n"
|
||||
" elementAttributeName: if present and not undefined, the name of\n"
|
||||
" property of 'element' that holds this code. This is what\n"
|
||||
" Debugger.Source.prototype.elementAttributeName returns.\n"
|
||||
" sourceMapURL: if present with value |v|, convert |v| to a string, and\n"
|
||||
" provide that as the code's source map URL. If omitted, attach no\n"
|
||||
" source map URL to the code (although the code may provide one itself,\n"
|
||||
@ -4270,9 +4270,9 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
|
||||
" mark the source as being attached to the DOM element |o|. If the\n"
|
||||
" property is omitted or |v| is null, don't attribute the source to\n"
|
||||
" any DOM element.\n"
|
||||
" elementProperty: if present and not undefined, the name of property\n"
|
||||
" of 'element' that holds this code. This is what Debugger.Source\n"
|
||||
" .prototype.elementProperty returns.\n"),
|
||||
" elementAttributeName: if present and not undefined, the name of\n"
|
||||
" property of 'element' that holds this code. This is what\n"
|
||||
" Debugger.Source.prototype.elementAttributeName returns.\n"),
|
||||
|
||||
JS_FN_HELP("runOffThreadScript", runOffThreadScript, 0, 0,
|
||||
"runOffThreadScript()",
|
||||
|
@ -3878,8 +3878,8 @@ DebuggerSource_getElement(JSContext *cx, unsigned argc, Value *vp)
|
||||
static bool
|
||||
DebuggerSource_getElementProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get elementProperty)", args, obj, sourceObject);
|
||||
args.rval().set(sourceObject->elementProperty());
|
||||
THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get elementAttributeName)", args, obj, sourceObject);
|
||||
args.rval().set(sourceObject->elementAttributeName());
|
||||
return Debugger::fromChildJSObject(obj)->wrapDebuggeeValue(cx, args.rval());
|
||||
}
|
||||
|
||||
@ -3888,7 +3888,7 @@ static const JSPropertySpec DebuggerSource_properties[] = {
|
||||
JS_PSG("url", DebuggerSource_getUrl, 0),
|
||||
JS_PSG("element", DebuggerSource_getElement, 0),
|
||||
JS_PSG("displayURL", DebuggerSource_getDisplayURL, 0),
|
||||
JS_PSG("elementProperty", DebuggerSource_getElementProperty, 0),
|
||||
JS_PSG("elementAttributeName", DebuggerSource_getElementProperty, 0),
|
||||
JS_PS_END
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user