/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "jsobj.h"
#include "jswrapper.h"

#include "jsapi-tests/tests.h"

#include "vm/ProxyObject.h"

const js::Class OuterWrapperClass =
    PROXY_CLASS_WITH_EXT(
        "Proxy",
        0, /* additional class flags */
        PROXY_MAKE_EXT(
            false,   /* isWrappedNative */
            nullptr  /* objectMoved */
        ));

static JSObject*
wrap(JSContext* cx, JS::HandleObject toWrap, JS::HandleObject target)
{
    JSAutoCompartment ac(cx, target);
    JS::RootedObject wrapper(cx, toWrap);
    if (!JS_WrapObject(cx, &wrapper))
        return nullptr;
    return wrapper;
}

static JSObject*
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "jsobj.h"
#include "jswrapper.h"

#include "jsapi-tests/tests.h"

#include "vm/ProxyObject.h"

static const js::ClassExtension OuterWrapperClassExtension = PROXY_MAKE_EXT(
    nullptr  /* objectMoved */
);

const js::Class OuterWrapperClass = PROXY_CLASS_WITH_EXT(
    "Proxy",
    0, /* additional class flags */
    &OuterWrapperClassExtension);

static JSObject*
wrap(JSContext* cx, JS::HandleObject toWrap, JS::HandleObject target)
{
    JSAutoCompartment ac(cx, target);
    JS::RootedObject wrapper(cx, toWrap);
    if (!JS_WrapObject(cx, &wrapper))
        return nullptr;
    return wrapper;
}

static void
PreWrap(JSContext* cx, JS::HandleObject scope, JS::HandleObject obj,
        JS::HandleObject objectPassedToWrap,