mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Add an empty Debug constructor into the shell and a JS_DefineDebugObject function to jsdbgapi.h.
This commit is contained in:
parent
54bbd588ec
commit
372f84a7c1
@ -137,6 +137,7 @@ CPPSRCS = \
|
||||
jscompartment.cpp \
|
||||
jsdate.cpp \
|
||||
jsdbgapi.cpp \
|
||||
jsdbg.cpp \
|
||||
jsdhash.cpp \
|
||||
jsdtoa.cpp \
|
||||
jsemit.cpp \
|
||||
|
73
js/src/jsdbg.cpp
Normal file
73
js/src/jsdbg.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is SpiderMonkey Debug object.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jim Blandy <jimb@mozilla.com>
|
||||
* Jason Orendorff <jorendorff@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsobj.h"
|
||||
|
||||
using namespace js;
|
||||
|
||||
static bool
|
||||
NotImplemented(JSContext *cx)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NEED_DIET, "API");
|
||||
return false;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Debug(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
return NotImplemented(cx);
|
||||
}
|
||||
|
||||
static Class DebugClass = {
|
||||
"Debug", 0,
|
||||
PropertyStub, PropertyStub, PropertyStub, StrictPropertyStub,
|
||||
EnumerateStub, ResolveStub, ConvertStub
|
||||
};
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_DefineDebugObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObject *objProto;
|
||||
if (!js_GetClassPrototype(cx, obj, JSProto_Object, &objProto))
|
||||
return NULL;
|
||||
|
||||
return !!js_InitClass(cx, obj, objProto, &DebugClass, Debug, 1,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
@ -524,6 +524,10 @@ JS_StopProfiling();
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
|
||||
|
||||
/* Defined in jsdbg.cpp. */
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_DefineDebugObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
#ifdef MOZ_CALLGRIND
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
|
@ -5705,6 +5705,8 @@ NewGlobalObject(JSContext *cx, CompartmentKind compartment)
|
||||
if (!JS_InitCTypesClass(cx, glob))
|
||||
return NULL;
|
||||
#endif
|
||||
if (!JS_DefineDebugObject(cx, glob))
|
||||
return NULL;
|
||||
if (!JS::RegisterPerfMeasurement(cx, glob))
|
||||
return NULL;
|
||||
if (!JS_DefineFunctions(cx, glob, shell_functions) ||
|
||||
|
10
js/src/tests/js1_8_5/extensions/debug-object-01.js
Normal file
10
js/src/tests/js1_8_5/extensions/debug-object-01.js
Normal file
@ -0,0 +1,10 @@
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
checkFunction(this, "Debug", 1);
|
||||
|
||||
assertEq(Debug.prototype.constructor, Debug);
|
||||
assertEq(Object.prototype.toString.call(Debug.prototype), "[object Debug]");
|
||||
assertEq(Object.getPrototypeOf(Debug.prototype), Object.prototype);
|
||||
|
||||
reportCompare(0, 0, 'ok');
|
@ -39,3 +39,4 @@ script regress-630377.js
|
||||
script regress-631723.js
|
||||
skip-if(!xulRuntime.shell) script regress-636818.js
|
||||
script regress-636697.js
|
||||
skip-if(!xulRuntime.shell) script debug-object-01.js
|
||||
|
@ -170,3 +170,14 @@ var Match =
|
||||
MatchError: MatchError };
|
||||
|
||||
})();
|
||||
|
||||
// used by several Debug object tests
|
||||
function checkFunction(obj, name, nargs) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, name);
|
||||
assertEq(desc.configurable, true, name + " should be configurable");
|
||||
assertEq(desc.writable, true, name + " should be writable");
|
||||
assertEq(desc.enumerable, false, name + " should be non-enumerable");
|
||||
assertEq(desc.value, obj[name]); // well obviously
|
||||
assertEq(typeof desc.value, 'function', name + " should be a function");
|
||||
assertEq(desc.value.length, nargs, name + " should have .length === " + nargs);
|
||||
}
|
||||
|
@ -279,6 +279,24 @@ if (typeof assertEq == 'undefined')
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof assertThrows === 'undefined') {
|
||||
var assertThrows = function assertThrows(f, ctor, msg) {
|
||||
var fullmsg;
|
||||
try {
|
||||
f();
|
||||
} catch (exc) {
|
||||
if (exc instanceof ctor)
|
||||
return;
|
||||
fullmsg = "Assertion failed: expected exception " + ctor.name + ", got " + exc;
|
||||
}
|
||||
if (fullmsg === undefined)
|
||||
fullmsg = "Assertion failed: expected exception " + ctor.name +", no exception thrown";
|
||||
if (msg !== undefined)
|
||||
fullmsg += " - " + msg;
|
||||
throw new Error(fullmsg);
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare expected result to actual result, if they differ (in value and/or
|
||||
* type) report a failure. If description is provided, include it in the
|
||||
|
Loading…
Reference in New Issue
Block a user