tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DOMProxy.cpp (1586B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 /* DOM proxy-related functionality, including expando support. */
      8 
      9 #include "js/friend/DOMProxy.h"  // JS::DOMProxyShadowsCheck
     10 #include "proxy/DOMProxy.h"
     11 
     12 #include "js/Proxy.h"  // js::GetProxyHandler, js::IsProxy
     13 
     14 using JS::DOMProxyShadowsCheck;
     15 
     16 static const void* gDOMProxyHandlerFamily = nullptr;
     17 static DOMProxyShadowsCheck gDOMProxyShadowsCheck = nullptr;
     18 static const void* gDOMRemoteProxyHandlerFamily = nullptr;
     19 
     20 void JS::SetDOMProxyInformation(const void* domProxyHandlerFamily,
     21                                DOMProxyShadowsCheck domProxyShadowsCheck,
     22                                const void* domRemoteProxyHandlerFamily) {
     23  gDOMProxyHandlerFamily = domProxyHandlerFamily;
     24  gDOMProxyShadowsCheck = domProxyShadowsCheck;
     25  gDOMRemoteProxyHandlerFamily = domRemoteProxyHandlerFamily;
     26 }
     27 
     28 const void* js::GetDOMProxyHandlerFamily() { return gDOMProxyHandlerFamily; }
     29 
     30 DOMProxyShadowsCheck js::GetDOMProxyShadowsCheck() {
     31  return gDOMProxyShadowsCheck;
     32 }
     33 
     34 const void* js::GetDOMRemoteProxyHandlerFamily() {
     35  return gDOMRemoteProxyHandlerFamily;
     36 }
     37 
     38 bool js::IsDOMRemoteProxyObject(JSObject* object) {
     39  return js::IsProxy(object) && js::GetProxyHandler(object)->family() ==
     40                                    js::GetDOMRemoteProxyHandlerFamily();
     41 }