Dactyloidae/js/src/jsapi-tests
2024-01-05 10:07:09 +08:00
..
jsapi-tests-gdb.py.in import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
Makefile.in import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
moz.build No Issue - Fix syntax in js/src/jsapi-tests/moz.build 2024-01-05 10:07:09 +08:00
README import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
selfTest.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testAddPropertyPropcache.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testArgumentsObject.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testArrayBuffer.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testArrayBufferView.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testAssemblerBuffer.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testBoundFunction.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testBug604087.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testCallArgs.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testCallNonGenericMethodOnProxy.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testChromeBuffer.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testClassGetter.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testCloneScript.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDateToLocaleString.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDebugger.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDeepFreeze.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDefineGetterSetterNonEnumerable.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDefineProperty.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDefinePropertyIgnoredAttributes.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testDeflateStringToUTF8Buffer.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testDifferentNewTargetInvokeConstructor.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testEnclosingFunction.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testErrorCopying.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testException.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testExternalArrayBuffer.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testExternalStrings.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testFindSCCs.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testForceLexicalInitialization.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testForOfIterator.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testForwardSetProperty.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testFreshGlobalEvalRedefinition.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testFunctionBinding.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testFunctionProperties.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testGCAllocator.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCCellPtr.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCChunkPool.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCExactRooting.cpp Issue #1742 - Part 1: Refactor rooting base class templates 2022-05-31 09:12:19 +08:00
testGCFinalizeCallback.cpp Remove remaining conditional GCZeal code. 2019-02-14 14:37:52 +08:00
testGCHeapPostBarriers.cpp Issue #1742 - Part 4: Don't trigger read barriers when comparing wrapped pointers types 2022-05-31 09:12:45 +08:00
testGCHooks.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testGCMarking.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCOutOfMemory.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testGCStoreBufferRemoval.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCUniqueId.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCWeakCache.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGCWeakRef.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testGetPropertyDescriptor.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testHashTable.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testIndexToString.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testIntern.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testIntlAvailableLocales.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testIntString.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testIntTypesABI.cpp Issue #1442 - Part 4: Add JSAPI functions for working with ReadableStream. https://bugzilla.mozilla.org/show_bug.cgi?id=1272697 2023-10-04 09:53:45 +08:00
testIsInsideNursery.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testIteratorObject.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testJitDCEinGVN.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitFoldsTo.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitGVN.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitMacroAssembler.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitMinimalFunc.h Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitMoveEmitterCycles-mips32.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitMoveEmitterCycles.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitRangeAnalysis.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitRegisterSet.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJitRValueAlloc.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testJSEvaluateScript.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testLookup.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testLooselyEqual.cpp Issue #2241 - Part 1: Move {js::,JS_}{{Strictly,Loosely}Equal,SameValue} into their own header and implementation files 2023-05-15 09:09:41 +08:00
testMappedArrayBuffer.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testMutedErrors.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testNewObject.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testNewTargetInvokeConstructor.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testNullRoot.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testObjectEmulatingUndefined.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testOOM.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testParseJSON.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testPersistentRooted.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testPreserveJitCode.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testPrintf.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testPrivateGCThingValue.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testProfileStrings.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testPromise.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testPropCache.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testReadableStream.cpp Issue #1442 - Part 4: Add JSAPI functions for working with ReadableStream. https://bugzilla.mozilla.org/show_bug.cgi?id=1272697 2023-10-04 09:53:45 +08:00
testRegExp.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testResolveRecursion.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
tests.cpp Issue #1442 - Part 4: Add JSAPI functions for working with ReadableStream. https://bugzilla.mozilla.org/show_bug.cgi?id=1272697 2023-10-04 09:53:45 +08:00
tests.h Issue #2241 - Part 1: Move {js::,JS_}{{Strictly,Loosely}Equal,SameValue} into their own header and implementation files 2023-05-15 09:09:41 +08:00
testSameValue.cpp Issue #2241 - Part 1: Move {js::,JS_}{{Strictly,Loosely}Equal,SameValue} into their own header and implementation files 2023-05-15 09:09:41 +08:00
testSavedStacks.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testScriptInfo.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testScriptObject.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testSetProperty.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testSetPropertyIgnoringNamedGetter.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testSharedImmutableStringsCache.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testSlowScript.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testSourcePolicy.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testStringBuffer.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testStructuredClone.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testSymbol.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testThreadingConditionVariable.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testThreadingExclusiveData.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testThreadingMutex.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testThreadingThread.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testToIntWidth.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testTypedArrays.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testUbiNode.cpp 1320408 - Part 2: Change JSFunction::getOrCreateScript to static method. 2019-07-22 19:47:27 +08:00
testUncaughtSymbol.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testUTF8.cpp Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00
testValueABI.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testWasmLEB128.cpp import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo 2018-01-19 03:59:58 +08:00
testWeakMap.cpp Issue #1656 - Part 10: Manual cleanup. 2020-09-25 22:07:01 +08:00
testXDR.cpp Issue #1952 - m-c 1383775: Clean up function toString/toSource code, remove remnants of source decompiler 2022-07-03 06:55:19 +08:00
valueABI.c Issue #1656 - Part 7: Nuke vim config lines in JS 2020-09-25 22:04:24 +08:00

# 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();