gecko/js/src/jsapi-tests
2015-09-10 16:24:00 +02:00
..
jsapi-tests-gdb.py.in
Makefile.in
moz.build Backout c9e469c6b915 (Bug 1196847) for regressing octane. 2015-09-03 09:38:04 -07:00
README Backed out 20 changesets (bug 1138499, bug 1148750, bug 1149563, bug 1148652, bug 1123875, bug 1145636, bug 1147660, bug 1148568, bug 1142828) for talos other timeouts CLOSED TREE 2015-04-01 19:17:45 -07:00
selfTest.cpp Bug 1131805 part 2. Remove remaining js::GetObjectParent and JS_GetParent uses in SpiderMonkey. r=waldo 2015-03-06 16:33:31 -05:00
testAddPropertyPropcache.cpp Bug 1177892 part 3 - Remove OBJECT_TO_JSVAL. r=evilpie 2015-06-30 21:09:46 -07:00
testArgumentsObject.cpp Bug 1177892 part 4 - Remove INT_TO_JSVAL. r=evilpie 2015-06-30 21:10:04 -07:00
testArrayBuffer.cpp Bug 1177892 part 4 - Remove INT_TO_JSVAL. r=evilpie 2015-06-30 21:10:04 -07:00
testArrayBufferView.cpp Bug 789589 - Implement JS_NewDataView, r=Waldo 2015-07-24 13:05:01 -07:00
testBug604087.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testCallNonGenericMethodOnProxy.cpp Bug 1198193 - Change all functions taking CallArgs to take const CallArgs& instead. r=Waldo 2015-08-27 21:18:37 +02:00
testChromeBuffer.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testClassGetter.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testCloneScript.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testContexts.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testDebugger.cpp Bug 1177892 part 4 - Remove INT_TO_JSVAL. r=evilpie 2015-06-30 21:10:04 -07:00
testDeepFreeze.cpp Bug 1177825 - Remove JSVAL_* constants. r=evilpie 2015-06-29 18:36:44 -07:00
testDefineGetterSetterNonEnumerable.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testDefineProperty.cpp
testDefinePropertyIgnoredAttributes.cpp Bug 1170959 - Remove JS_GetPropertyDescriptor from a JSAPI test. r=efaust 2015-06-05 21:36:47 +02:00
testDifferentNewTargetInvokeConstructor.cpp Bug 1173525 - Add JS::Construct overload for specifying new.target. (r=Waldo) 2015-06-17 14:37:48 -07:00
testEnclosingFunction.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testErrorCopying.cpp Bug 1173787. The column number of an exception populated via PopulateReportBlame should be 1-based. r=fitzgen 2015-06-12 22:21:44 -04:00
testException.cpp
testExternalStrings.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testFindSCCs.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testForOfIterator.cpp
testForwardSetProperty.cpp Bug 1155006: Fix unified build sensitivities in js/src. r=shu 2015-04-15 17:50:15 -07:00
testFreshGlobalEvalRedefinition.cpp Bug 1155946 part 1 - Add a mayResolve class hook to optimize objects with resolve hooks better. r=bhackett 2015-04-23 15:51:28 +02:00
testFunctionProperties.cpp Bug 1177825 - Remove JSVAL_* constants. r=evilpie 2015-06-29 18:36:44 -07:00
testGCAllocator.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testGCCellPtr.cpp Bug 1167453 - Rename JSGCTraceKind and make it a C++11 enum class; r=jonco 2015-05-22 10:40:24 -07:00
testGCChunkPool.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testGCExactRooting.cpp Bug 1189490 - Follow ups: Move [Traceable]Fifo to js/src/ds. r=terrence 2015-08-10 13:15:00 -04:00
testGCFinalizeCallback.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testGCHeapPostBarriers.cpp Bug 1142816 - js/src/jsapi-tests/testGCHeapPostBarriers.cpp has leaks. r=erahm 2015-05-27 10:30:36 +02:00
testGCMarking.cpp Bug 1173889 - Strongly type the CallbackTracer dispatch function; r=jonco, r=mccr8 2015-06-11 10:03:33 -07:00
testGCOutOfMemory.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testGCStoreBufferRemoval.cpp Backout 7959ffacd30f (Bug 1176090) for being on top of a regression. 2015-06-24 16:20:31 -07:00
testGetPropertyDescriptor.cpp Bug 1124935 - Remove LookupProperty from JS_GetPropertyDescriptor. r=efaust,bz 2015-02-06 15:43:20 +01:00
testHashTable.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testIndexToString.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testIntern.cpp Bug 1178581 - Interning does not and should not imply infinite lifetime; r=sfink 2015-06-30 07:58:31 -07:00
testIntlAvailableLocales.cpp Bug 1175347 - Add a JSAPI test for exposing availability of locales derived from the default locale. r=itsatest, rs=till over IRL 2015-06-26 17:49:18 -07:00
testIntString.cpp Bug 1178581 - Interning does not and should not imply infinite lifetime; r=sfink 2015-06-30 07:58:31 -07:00
testIntTypesABI.cpp Bug 1127156 - Rework optimization tracking JSAPI to be more usable from the profiler. (r=djvj) 2015-02-04 13:40:02 -08:00
testIsInsideNursery.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testJitDCEinGVN.cpp Bug 1171945: IonMonkey: Use tryXXX structure for jsop_binary in IonBuilder, r=jandem 2015-08-14 12:45:47 +02:00
testJitFoldsTo.cpp Bug 1171945: IonMonkey: Use tryXXX structure for jsop_binary in IonBuilder, r=jandem 2015-08-14 12:45:47 +02:00
testJitGVN.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testJitMinimalFunc.h Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testJitMoveEmitterCycles-mips32.cpp Bug 1182936 part 2 - IonMonkey: MIPS32: Move mips macros to mips32. r=nbp 2015-08-12 11:22:01 +02:00
testJitMoveEmitterCycles.cpp Bug 1173992 - Add ARM64 build support. r=glandium 2015-06-11 15:03:20 -07:00
testJitRangeAnalysis.cpp Bug 1176288 - Part 3: Rename CompareV to CompareBitwise, r=jandem 2015-09-10 14:50:20 +02:00
testJitRegisterSet.cpp Bug 1143011 - Use AllocatableSet or LiveSet for all register set uses. r=jandem 2015-03-28 01:08:12 +01:00
testJitRValueAlloc.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testJSEvaluateScript.cpp Bug 1171177 - Remove VAROBJFIX. (r=luke) 2015-06-21 11:49:58 -07:00
testLookup.cpp Bug 1177825 - Remove JSVAL_* constants. r=evilpie 2015-06-29 18:36:44 -07:00
testLooselyEqual.cpp Bug 1177892 part 5 - Remove DOUBLE_TO_JSVAL. r=evilpie 2015-07-17 11:51:52 +02:00
testMappedArrayBuffer.cpp Bug 1177892 part 3 - Remove OBJECT_TO_JSVAL. r=evilpie 2015-06-30 21:09:46 -07:00
testMutedErrors.cpp Bug 1142826 - js/src/jsapi-tests/testMutedErrors.cpp has leaks. r=luke 2015-05-13 22:47:47 +02:00
testNewObject.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testNewTargetInvokeConstructor.cpp Bug 1141865 - Part 3: Parse new.target, add Reflect support, and tests. (r=jorendorff, r=shu) 2015-06-03 02:01:15 -07:00
testNullRoot.cpp
testObjectEmulatingUndefined.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testOOM.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testOps.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testParseJSON.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testPersistentRooted.cpp Bug 1088214 - Remove JSCLASS_IMPLEMENTS_BARRIERS now this is implemented everywhere r=terrence 2015-09-02 10:40:10 +01:00
testPreserveJitCode.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testProfileStrings.cpp Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testPropCache.cpp Bug 1147005 - Change JSAddPropertyOp signature. r=jorendorff,peterv 2015-03-28 14:47:02 +01:00
testRegExp.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testResolveRecursion.cpp Bug 1177825 - Remove JSVAL_* constants. r=evilpie 2015-06-29 18:36:44 -07:00
tests.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
tests.h Bug 1184564 part 4 - Use Value instead of jsval in SpiderMonkey. r=evilpie 2015-07-18 21:45:35 +02:00
testSameValue.cpp Bug 1132045 - Add handles to various equality operations. r=jandem 2015-02-17 15:03:23 +01:00
testSavedStacks.cpp Bug 1202028 - Implement range based for loops for SavedFrame stacks. r=terrence 2015-09-10 16:24:00 +02:00
testScriptInfo.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testScriptObject.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testSetProperty.cpp Bug 1177892 part 4 - Remove INT_TO_JSVAL. r=evilpie 2015-06-30 21:10:04 -07:00
testSetPropertyIgnoringNamedGetter.cpp Bug 1158222 - Implement the new [[Set]] receiver restrictions. r=jorendorff 2015-05-22 18:31:32 +02:00
testSlowScript.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testSourcePolicy.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testStringBuffer.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testStructuredClone.cpp
testSymbol.cpp
testToIntWidth.cpp
testTypedArrays.cpp Bug 1177892 part 4 - Remove INT_TO_JSVAL. r=evilpie 2015-06-30 21:10:04 -07:00
testUbiNode.cpp Bug 1196634 - Part 0: Define a JS::ubi::CoarseType enum; r=sfink 2015-08-27 16:16:57 -07:00
testUncaughtError.cpp Bug 1164602 - Replace js::NullPtr and JS::NullPtr with nullptr_t; r=sfink 2015-05-13 14:07:34 -07:00
testUTF8.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testValueABI.cpp Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|. r=jorendorff 2015-03-28 23:22:11 +01:00
testWeakMap.cpp Bug 1164294 - Implement a linear-time ephemeron marking algorithm, r=terrence, r=jonco 2015-08-12 16:55:40 -07:00
testXDR.cpp Bug 1177825 - Remove JSVAL_* constants. r=evilpie 2015-06-29 18:36:44 -07:00
valueABI.c

# JSAPI Test Suite

The tests in this directory exercise the JSAPI.


## Building and running the tests

If you built JS, you already built the tests.

The tests are built by default when you build JS. All the tests are compiled
into a single binary named jsapi-tests. They all run in a single process.

To run the tests:

    cd $OBJDIR/dist/bin
    ./jsapi-tests

To run the tests in a debugger:

    cd $OBJDIR/dist/bin
    gdb ./jsapi-tests


## Creating new tests

1.  You can either add to an existing test*.cpp file or make a new one.
    Copy an existing test and replace the body with your test code.
    The test harness provides `cx`, `rt`, and `global` for your use.

2.  If you made a new .cpp file, add it to the UNIFIED_SOURCES list
    in moz.build.


## Writing test code

Here is a sample test:

    #include "tests.h"

    BEGIN_TEST(testIntString_bug515273)
    {
        RootedValue v(cx);

        EVAL("'42';", &v);
        JSString *str = v.toString();
        CHECK(JS_StringHasBeenInterned(cx, str));
        CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(str), "42"));
        return true;
    }
    END_TEST(testIntString_bug515273)

The BEGIN_TEST and END_TEST macros bracket each test. By convention, the test
name is <testFilename>_<detail>. (The above test is in testIntString.cpp.)

The curly braces are required. This block is the body of a C++ member function
that returns bool. The test harness calls this member function
automatically. If the function returns true, the test passes. False, it fails.

JSAPI tests often need extra global C/C++ code: a JSClass, a getter or setter
function, a resolve hook. Put these before the BEGIN_TEST macro.

The body of the test can use these member variables and macros, defined in
tests.h:

    JSRuntime *rt;
    JSContext *cx;
    JSObject *global;

        The test framework creates these fresh for each test. The default
        environment has reasonable default settings, including
        JSOPTION_VAROBJFIX, JSOPTION_JIT, a global object of a class with
        JSCLASS_GLOBAL_FLAGS, and an error reporter that prints to stderr.
        See also "Custom test setup" below.

    EXEC(const char *code);

        Execute some JS code in global scope, using JS::Evaluate. Return
        false if that fails. (This means that if the code throws an uncaught JS
        exception, the test fails.)

    EVAL(const char *code, jsval *vp);

        Same as EXEC, but store the result value in *vp.

    CHECK(bool cond);

        If the condition is not true, print an error message and return false,
        failing the test.

    CHECK_SAME(jsval a, jsval b);

        If a and b are different values, print an error message and return
        false, failing the test.

        This is like CHECK(sameValue(a, b)) but with a more detailed error
        message on failure. See sameValue below.

    CHECK_EQUAL(const T &a, const U &b);

        CHECK(a == b), but with a more detailed error message.

    CHECK_NULL(const T *ptr);

        CHECK(ptr == nullptr), but with a more detailed error message.

        (This is here because CHECK_EQUAL(ptr, nullptr) fails to compile on GCC
        2.5 and before.)


    bool knownFail;

        Set this to true if your test is known to fail. The test runner will
        print a TEST-KNOWN-FAIL line rather than a TEST-UNEXPECTED-FAIL
        line. This way you can check in a test illustrating a bug ahead of the
        fix.

        If your test actually crashes the process or triggers an assertion,
        this of course will not help, so you should add something like

            knownFail = true;  // see bug 123456
            return false;  // the code below crashes!

        as the first two lines of the test.

    bool isNegativeZero(jsval v);
    bool isNaN(jsval v);

        Self-explanatory.

    bool sameValue(jsval v1, jsval v2);

        True if v1 and v2 are the same value according to the ES5 SameValue()
        function, to wit:

        SameValue(NaN, NaN) is true.
        SameValue(-0, 0) is false.
        Otherwise SameValue(a, b) iff a === b.


## Custom test setup

Before executing each test, the test framework calls the tests' init() member
function, which populates the rt, cx, and global member variables.

A test can customize the test setup process by overloading virtual member
functions, like this:

    const JSClass globalClassWithResolve = { ... };

    BEGIN_TEST(testGlobalResolveHook)
        {
            RootedValue v;
            EVAL("v", v.address());
            CHECK_SAME(v, JSVAL_VOID);
            return true;
        }

        // Other class members can go here.

        // This one overloads a base-class method.
        virtual JSClass *getGlobalJSClass() {
            return &globalClassWithResolve;
        }
    END_TEST(testGlobalResolveHook)

The overloadable member functions are:

    virtual bool init();
    virtual void uninit();
    virtual JSRuntime * createRuntime();
    virtual JSContext * createContext();
    virtual JSClass * getGlobalClass();
    virtual JSObject * createGlobal();