mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-13 11:59:51 +00:00
4ec2685f57
- Bug 1239496 - Load the UA sheet lazily so we can invalidate it for pref changes. Make it depend on the "layout.css.grid.enabled" pref. r=heycam (e4a1ac18b4)
- Bug 1225192 - fix eslint complaints about css-logic.js; r=pbrosset (ef19819c21)
- Bug 1225192 - remove leading whitespace before prettifying css; r=pbrosset (6b39d08907)
- Bug 1230491 - rewrite CssLogic.isContentStylesheet; r=bgrins (14c86cee67)
- Bug 1230491 - add CSSStyleSheet::parsingMode; r=heycam,bz (9ecabe232e)
- Bug 1239336 - set parsing mode on about:PreferenceStyleSheet; r=heycam,bgrins (cac07e099f)
- Bug 1224433 - Part 1: Add reftest. r=roc (28c8a47812)
- Bug 1195491 - use nsCOMPtr in RDFContentSinkImpl; r=bsmedberg (9804abe22e)
- Bug 1205713 - Merge ImageHostOverlay/ImageClientOverlay to ImageHost/ImageClient r=nical (2871e70466)
- Bug 1234472 - Add gonk sideband stream handling to gfx ipc r=nical (559f788a10)
- Bug 1049296 - Handle Sideband stream compositing in HwcComposer2D r=mwu,nical (b6dbac1a1b)
- Bug 1237508 - Odin: move GC allocation up to fix spurious hazard warning (there was an AutoKeepAtoms already) (r=hazard-red) (b5d0e54993)
- Bug 1229399: Group all IR's enums into a single one; r=luke (a7cfedc16a)
- Bug 1229399: Make {Get,Set}{Loc,Glo} opcodes type-independent; r=luke (0ed8e44098)
- Bug 1239211 - Odin: tweak wasm::Decoder (r=bbouvier) (980e08dc1e)
- Bug 1229399: Implement write/readVarU32 and use it for locals/globals; r=luke (5a6f654a14)
- Bug 1229399: Unite all the Emit* functions in WasmIonCompile; r=luke (64e517d18f)
- Bug 1240524: Fix AsmJS checkedValueType of Bool32x4; r=luke (d98ee763c7)
- Bug 1229399: Add list of wasm opcodes described in v8 design document; r=luke (1e05832624)
- Bug 1241339 - ObserverService may keep Console object alive until shutdown, r=baku (330d9e7bc0)
- Bug 1239177 - Odin: make calls more like wasm (r=bbouvier) (4bab27c7bc)
- Bug 1234985 - Odin: hoist read/writeOp into wasm::Decoder/Encoder (r=bbouvier) (de3ba3c3f9)
- Bug 1229399: Add test file forgotten in previous rebase/checkin; r=bustage (a2bdda0e86)
- Bug 1234985 - Odin: tweak ModuleGenerator interface for Baldr use (r=bbouvier) (5f52fd6777)
- Bug 1234985 - BaldrMonkey: testing-only (not content visible) wasm hello world (r=bbouvier) (e49e7f4db2)
- Bug 1234985 - Fix js/src/asmjs build errors with unified builds disabled. r=luke (acb7954471)
- Bug 1231335 - part 1, runtime switch for SAB+Atomics. r=waldo (973eb7edc1)
- Bug 1231335 - part 2, asm.js runtime SAB+Atomics gating. r=luke (b40a8d0b3f)
- Bug 1225040 - generalize jsapi-tests for SAB. r=arai (29240f91e1)
- Bug 1232211 - Don't perform various SharedArrayBuffer-centric typed array tests in builds with SharedArrayBuffer disabled (i.e. Aurora at next uplift). rs=lth over IRC, responding to cassandra!philor's concerns (f3df4b0c17)
- Bug 1231335 - part 3, testing functions and test cases. r=waldo (b91910ea28)
- Bug 1231335 - part 4, js shell. r=waldo (4a96addbde)
- Bug 1234985 - Odin: move mutedError and displayURL into AsmJSModule (r=bbouvier) (6be0172a15)
- Bug 1229399: Remove expression statements opcodes in wasm; r=luke (a046188e98)
- Bug 1229399: Allow to peek into the internal wasm IR; r=luke (f4b0497d89)
- Bug 1234985 - Odin: make names optional and supplied at the end (r=b ouvier) (ee7864fe7e)
- Bug 1238679 - Rename s/SIMD/Simd/ in type and function names. r=bbouvier (1d6c277644)
- Bug 1238679 - Add enum class SIMDOperation. r=bbouvier (eb7ce840da)
- Bug 1187232 - Access TypedArray's [[ArrayLength]] instead of performing property access; r=Waldo (a66850e72f)
- Bug 1239068 - Inline "PossiblyTypedArrayLength" intrinsic; r=Waldo (1a39045055)
- Bug 1238679 - Put JSJitInfo::depth in anonymous union. r=nbp (64d6859ee2)
- Bug 1238679 - Provide per-operation JSJitInfo for the SIMD functions. r=bbouvier (cd242c1f5d)
- Backed out changeset 7bda46f81215 (bug 1225031) for spidermonkey test failures (7c7de9af43)
- Bug 1225031 - get rid of the AnyTypedArray abstraction (updated). r=waldo (a8e3593280)
- Bug 1237284: Make inlineSimd* functions take MIRType to avoid an indirection; r=jolesen (c046f5ac06)
- Bug 1238679 - Make inlineSimdLoad/Store take a MIRType argument. r=bbouvier (7aceb59fc1)
- Bug 1238679 - Implement main SIMD inlining dispatch. r=bbouvier (3b19775b14)
- Bug 1237445 - Use GCHashMap for VMWrapperMap, r=terrence (4a5b3a1575)
- Bug 1241454: Hoist SimdTypeDescr::Type into SimdType, unify AsmJSSimdType and SimdType; r=jolesen (6cf5f03517)
- Bug 1241454: Unify AsmJSSimdOperation and SimdOperation; r=jolesen (7506dec0e4)
- Bug 1241454: Change SIMD opcodes encoding in wasm; r=luke, r=jolesen (afa2b74cab)
- Bug 1242804 - Baldr: check enum limits (r=bbouvier) (1a68daa1c3)
- Bug 1242804 - Baldr: add local/get_local/set_local (r=bbouvier) (cc2448d2e9)
- Bug 1243239 - Baldr: tighten signature index check (r=bbouvier) (fd7081ab39)
- Bug 1243373: Ensure all declared functions are defined; r=luke (3c42295668)
- Bug 1243031: Throw when WebAssembly is not supported; r=luke (ade7cdc6a6)
- Bug 1242772 - Baldr: fix unterminated string literal (r=bbouvier) (273e26e669)
- Bug 1241886: Fix debug assertion if we're in dead code; r=luke (59c009191b)
- Bug 1234985 - Odin: use VarU32 for integer literals (r=bbouvier) (62c7292462)
- Bug 1234985 - Odin: stop requiring explicit final return (r=bbouvier) (2a8bf1639e)
- Bug 1242949: Implement Block in WebAssembly; r=luke (e8997f2a2e)
- Bug 1242949: Add explicit keyword to WasmAstBlock ctor; r=bustage (239cdcf5d4)
- Bug 1243626 - Baldr: tweak block text format (r=bbouvier) (a6fe9248ce)
- Bug 1243252 - Baldr: refactor exports (r=bbouvier) (49ca6f519f)
- Bug 1243632 - Baldr: check TypeError vs. SyntaxError (r=bbouvier) (c70ab8e8ec)
- Bug 1243252 - Baldr: add import section (r=bbouvier) (16b98660c8)
- Bug 1243633 - Baldr: add call/call_import (r=bbouvier) (63dd480e7d)
- Bug 1234985 - Hoist CStringHasher (r=sfink) (c019cff4b3)
- Bug 1237445 - Implement GCRekeyableHashMap, r=terrence (c4acd75ad0)
- Bug 1244272 - BaldrMonkey: Implement support for i32.add. r=luke (ede8918dfe)
- Bug 1244272 - BaldrMonkey: Implement the rest of the i32 binary operators. r=luke (bf11a38b86)
- Bug 1244272 - BaldrMonkey: Implement the f32 and 64 operators. r=luke (2ea37d6a95)
- Bug 1244403 - Baldr: move kind out of WasmAstNode and into WasmAstExpr (r=bbouvier) (498fd0b4a5)
- Silence a GCC warning in JitCompartment.h. No bug#, rs=jandem on IRC. (a23ccc42b3)
- Bug 1237445 - Use GCHashMap for ICStubCodeMap, r=terrence (b1d970f3c9)
- Bug 1244403 - Baldr: remove unnecessary 'end' argument from (r=bbouvier) (8da28c587c)
- Bug 1244403 - Baldr: expose export func entry offsets directly (r=bbouvier) (c6f82070fb)
- Bug 1234862 - Part 2: Always use DefaultGCPolicy with GCVector; r=sfink (6d8cf44216)
- Bug 1237445 - Use GCHashTables for ObjectGroup sweeping, r=terrence (7fd47cc6fb)
- Bug 1237445 - Use GCHashMap for (CCW) WrapperMap, r=terrence (cf6788b6a4)
- Bug 1237447 - Disable the crashreporter when crashing intentionally in TestPLDHash. r=njn (d4744f47d4)
- Bug 1237445 - Rekey ArrayObjectTable, r=terrence (2ccfca974c)
- Bug 1234862 - Part 3: Always use DefaultGCPolicy for GCHashTables; r=sfink (d0f2472c1b)
- Bug 1234862 - Part 4: Always use DefaultGCPolicy for TraceableFifo; r=sfink (069e134534)
- Bug 1239494 - Use GCHashMap to simplify nsWrapperCache; r=jonco (0bb0069fc4)
- Bug 1234862 - Part 5: Rename DefaultGCPolicy to GCPolicy; r=sfink (cb93f0c133)
- Bug 1234862 - Part 5.1: Followup comment fixes; r=sfink (bd2930ddf2)
- Fix recent non-unified build bustage (no bug, rs=sunfish) (6c40eba8bc)
- Bug 1243815: Put hard limits to some variable lengths in wasm; r=luke (1df12aa08e)
- Bug 1244403 - Baldr: factor out DynamicLinkData (r=bbouvier) (f257b901a3)
- Bug 1244403 - Baldr: put import section first (r=bbouvier) (47e726c907)
- Bug 1244571 - BaldrMonkey: Implement the unary operators. r=luke (e22132ccb1)
- Bug 1244571 - BaldrMonkey: Implement the comparison operators. r=luke (aa6e7a71cd)
- Bug 1244571 - BaldrMonkey: Implement parsing, encoding, and decoding for the conversion operators. r=luke (73d65dc416)
- Bug 1244571 - BaldrMonkey: Type-check the unary and binary operators. r=luke (4d7d41d49b)
- Bug 1244571 - BaldrMonkey: Implement parsing, encoding, and decoding for i64 operators. r=luke (c42a9b5496)
- Bug 1244571 - BaldrMonkey: Improve the readability of the parser code. r=luke (298c9c57a5)
- Bug 1244571 - BaldrMonkey: Fail decoding for operators which are not yet implemented r=luke (fdd4deff21)
- Bug 1245250 - BaldrMonkey: Refacfor min/max to make variadicity AsmJS-specific r=luke (f30e0471b9)
- Bug 1242342: Add If and IfElse to WebAssembly; r=luke (653223fdd3)
- Bug 1247755 - Baldr: disallow duplicate signature table entries (r=sunfish) (419fd0be57)
- Bug 1234397 - dispatch on the correct value. r=luke (4c7d5f5105)
- Bug 1233863 - ARM64: Allow test to pass with --no-asmjs, and when no JIT exists. r=luke (b89522c52c)
- Bug 1244405 - Odin: switch to dynamic page size, move heap constants to Wasm (r=bbouvier) (31d4b684b7)
- Bug 1234038 - Self-host ArrayBuffer.prototype.slice. r=lth (ab81205e4a)
- Bug 1121937 - Implement %TypedArray%.prototype.sort; r=jorendorff (aef7bb1228)
- Bug 1101256 - Implement detachment checks for %TypedArray% methods (patch 1 of 2); r=Waldo (cb13a5078b)
- Bug 1101256 - Implement detachment checks for %TypedArray% methods (patch 2 of 2); r=Waldo (b429b87a3d)
- Bug 715181 - Self-host Array.sort; r=till (f87f85634c)
- Bug 1079844 - Adjust TypedArray.js comments to refer to detachment rather than neutering. r=mrrrgn (ac2b366958)
- Bug 1079844 - Rename scattered bits of 'neuter' terminology to detachment terminology. r=jandem (ae20a9677c)
- Bug 1079844 - Rename JS_ARRAYBUFFER_NEUTERED_FLAG to use detachment terminology. r=sfink (670281d8b0)
- Bug 1079844 - Rename isNeutered() to isDetached(), and rename isNeutered() on views to hasDetachedBuffer(). r=sfink (b5595746aa)
- Bug 1079844 - Convert the JS_NeuterArrayBufferObject API to detachment terminology. r=till (2d176589bd)
- Bug 1079844 - Rename JS_IsNeuteredArrayBufferObject to JS_IsDetachedArrayBufferObject. r=till (9607cf673d)
- Bug 1079844 - Refer to "detaching" instead of "neutering" of ArrayBuffers, in JIT optimization tracking code. r=jandem (a4a17233d0)
- Bug 1079844 - Rename TI's ObjectKey flag to use detachment terminology. r=jandem (8865017109)
- Bug 1079844 - Rename CheckForNeuteredTypedObject and the flag underlying it to use detachment terminology. r=jandem (67ace7669e)
- Bug 1079844 - Rename ABO::neuter to ABO::detach. r=sfink (37c71de755)
- Bug 1079844 - Rename ArrayBufferViewObject::neuter to ABVO::notifyBufferDetached. Detachment applies only to ArrayBuffers, and the methods didn't actually neuter anything, so "notify" makes more sense as the verb here. r=sfink (2ebf7779a7)
- Bug 1079844 - Rename ABO::neuterView to a standalone NoteViewBufferWasDetached function. r=sfink (3ce2977123)
- Bug 1244405 - Odin: refactor ArrayBufferObject::createForWasm out of prepareForAsmJS (r=bbouvier) (3f5ed523f0)
- Bug 1243633 - Odin: tidy up call emitting (r=bbouvier) (89256a6d57)
- Bug 1243633 - Odin: switch to lineOrBytecode from line/column (r=bbouvier) (ded5ff23de)
- Bug 1242342: Set return type accordingly to the compilation mode; r=luke (f4cdff1644)
- Bug 1244405 - Baldr: fix wasm function export name (r=bbouvier) (c6ea5f8194)
- Bug 1244405 - Baldr: add memory section (r=bbouvier) (c98fc66e50)
- Bug 1243252 - Remove const restriction on CharsToNewUTF8CharsZ (r=jandem) (9ef020aff6)
- fix neutered/detached (2a675ae62e)
- Bug 1242342: Replace Ternary by IfElse which return expressions; r=luke (aa1535de89)
- Bug 1244405 - Baldr: add memory exports (r=bbouvier) (9a495599df)
- Bug 1240583 - Odin: remove the sync interrupt stub (r=bbouvier) (a3811b0cc5)
- Bug 1242043 - {Array,%TypedArray%}.prototype.{i,lastI}ndexOf should never return -0. r=jorendorff (485f5d62dc)
- Bug 1180290 - Part 1: Add prefix parameter to IdToFunctionName. r=till (e33ed94f64)
- Bug 1180290 - Part 2: Handle prefix in DefinePropertyById. r=till,smaug (5c3333ef68)
- Bug 1180290 - Part 3: Use canonical name in native getter. r=till (213b6d1b7f)
- Bug 1180290 - Part 4: Add tests for builtin getter name. r=till (005f1e4da7)
- Bug 1180290 - Part 5: Remove getter/setter variant for ThrowInvalidThis message. r=bz (fa8224af50)
- Bug 1236548 - Allow JS_UNINITIALIZED_LEXICAL in jit::InvokeFunction. (r=Waldo) (33b1f88506)
- Bug 1212533 - Change the out-param of js/JS::Construct from MutableHandleValue to MutableHandleObject. r=arai, r=jorendorff (7910b24126)
- Bug 1233857 - Teach the JIT how to put individual elements' edges in the store buffer; r=jandem (7d0b35b028)
- Bug 1236548 - Followup: Make added test actually pass. (rs=Waldo) (0f1e6861b1)
- Bug 1216166 - Unify CustomEvent.cpp with the rest of the unified sources, r=smaug (eacd905246)
- Bug 1233831 - Part 0: JSAPI plumbing for nursery collection callbacks; r=terrence (1417ff456a)
- Bug 1233831 - Part 1: Call the callback on nursery collections; r=terrence (cf720fc8c9)
- Bug 1233831 - Part 2: Expose JS::gcreason::ExplainReason to embedders; r=terrence (5eaceb2a58)
- Bug 1233831 - Part 3: Install a callback to trace nursery collections; r=mccr8 (13bc8d19ff)
- Bug 1233831 - Part 4: Add metadata for the minor GC markers; r=vporof (cb42e1e42a)
- Bug 1233831 - Part 5: Test the minor GC markers; r=vporof (5f8ae59242)
- Bug 1218468 - Remove worker markers on each check in browser_timelineMarkers-02.js, r=me (33efc054c0)
- Bug 1233831 - Follow up: Expand sanitizeMarkers to filter out minor GC markers; r=jsantell (b99fb1dbbc)
- Bug 1239314 - Make marking validation a normal zeal mode; r=jonco (4668054d11)
- Bug 1233857 - Follow up: Add a new GC zeal mode for the elements edges barrier; r=terrence (61a7db4357)
- Bug 1245767 - Allow combining different gczeal modes. r=terrence (8d90fd103e)
- Bug 1242262 - Remove the last vestiges of JS_GC_MARKING_VALIDATION (it's a GC Zeal mode now). r=terrence (3ca086aed4)
- Bug 1249795 - Clear strong refs to message managers once we've destroyed nsFrameLoader, r=billm (b562395eb9)
- Bug 1244405 - Baldr: add memory segments (r=sunfish) (c7850ee495)
- Bug 1246433 - BaldrMonkey: Implement integer and float literals. r=luke (d668caa1bd)
- Bug 1240583 - Odin: refactor x86/x64 loads/stores (r=sunfish) (df85bc0aa3)
- Bug 1240583 - Odin: replace retargetWithOffset (r=bbouvier) (627815cb6d)
- Bug 757969 - use __thread in ThreadLocal; r=froydnj (5e06f7ef9e)
- bug 1244128 - stop exporting js friend api symbols from libxul r=glandium (894792316d)
- Bug 912337 - Make a new Error subclass: Debugger.DebuggeeWouldRun. (r=jimb) (a020dfd40c)
- Bug 1248101 - Make dtoa_malloc infallible. r=sfink. (0828c1b15b)
- Bug 1245737 (part 1) - Enable |Omit_Private_Memory| for our dtoa implementation. r=bhackett. (aaa0ebad66)
- Bug 1245737 (part 0) - Fix a leak in DtoaState. r=sfink. (3007242e86)
- Bug 1245737 (part 2) - Don't bother measuring DtoaState. r=bhackett. (db33501ddd)
- Bug 1243888 - Derive RootKind automatically from TraceKind; r=sfink (08421e1c6c)
- Bug 1244358 - Support all types in PersistentRooted; r=sfink (bc1a8ada00)
- Bug 1248233. Make js::ReportOutOfMemory respect the autoJSAPIOwnsErrorReporting() flag on the context options. r=luke (5ee05b61e6)
- Bug 1235151 - Factor all the install.rdfs used for langpacks. r=mshal (0e10679502)
- Bug 1235151 - Use #include in toolkit/locales/generic/install.rdf instead of -I on the preprocessor command line. r=mshal (31fdfea3de)
- Bug 1227388 - Finish removing dehydra support. r=mshal (aa43dfce95)
- Bug 1205814 - mozilla eslint plug: allow top level var only r=pbrosset (f247252d4b)
- Bug 1218409 - Eslint rule that checks for balanced listeners. r=miker (45d42a1014)
- Bug 1205814 - Missed a brief description in rst docs r=pbrosset (13fb24c5c4)
- Bug 1218425 - ESLint rule that warns against aArg notation in function params; r=miker (e811f2c8f7)
- Bug 1217851 - Fix mozplugin's import-headjs-globals on Windows. r=pbro (685f450fcb)
- Bug 1218412 - Create ESLint rule to check for CPOWS in browser mochitests r=pbrosset (c505ab4ed3)
- Bug 1217922 - eslint head.js plugin does not seem to work r=pbrosset (8d3782057e)
- Bug 1224735 - don't use "for..of" in eslint plugin. r=miker (90ecebec24)
- Bug 1225289 - Make eslint plugin code conform to .eslintrc r=pbrosset (007bf4c6b8)
- Bug 1222232 - Help mach eslint find espree and escope r=pbrosset (d0f7c5987b)
- Bug 1229858: Add a preprocessor to convert XBL into JavaScript blocks for eslint. r=miker (99bd8d62c4)
- Bug 1230300: Fix mach eslint to pass command arguments through to eslint. r=gps (7b54b30a8f)
- Bug 1231720 - Log when ESLint finishes running. r=nalexander (12705e260d)
- Bug 1234164 - Fix Ion GETNAME stubs to check for uninitialized lexicals. (r=efaust) (561d6e2d1c)
- Bug 1239519 - Fix debug-only initializion order issue detected by ASan. r=luke (8aa8b63fb6)
- Bug 1242840 - Drop profiler invalidation event if we hit OOM and make invalidation infallible r=jandem (8dfe4d99a5)
- Bug 1232386 - Fix NativeObject::growSlotsStatic to recover from OOM. r=terrence (284f47d6b1)
- Bug 1235032 - check value of obj, remake while () {} to do { } while(). r=jorendorff (0cb646a76e)
- Bug 1228327 - Fix bogus assert in GenerateDenseElementHole, add some comments. r=bhackett (e7fc0db6a0)
- Bug 1232859 - Don't crash or abort compilation if we're unable to compile the regex stubs. r=nbp (0ec48d44b5)
- Bug 1237566 - Bake in global this-value in IonBuilder::jsop_functionthis in some cases. r=h4writer (bd1fb0e8d8)
- Bug 1000780 - Part 7: Fix perf regressions introduced in part 1. r=jandem (629452aa16)
- Bug 1240100: IonMonkey: Magic values cannot flow through an instruction, r=jandem (f644caf377)
- Bug 1244098 - Attempt to fold JSOP_IN to false in IonBuilder based on TI. r=bhackett (e964e1d2bf)
- Bug 1238592 - IonMonkey: Optimize away any OSR fixup blocks that are ultimately unreachable. r=nbp (3e7ad0d61a)
- Bug 1245171 - Ensure enough ballast space in js::jit::AddKeepAliveInstructions. r=jandem (ba48c30163)
- Bug 1244828 - Ensure enough ballast space in TypeAnalyzer::adjustPhiInputs. r=h4writer (126c899284)
- Bug 1244828 - Ensure enough ballast space in TypeAnalyzer::adjustInputs. r=h4writer (0bf3d584b9)
- Bug 1112537 - Optimize String#split('foo').join('bar') pattern. r=nbp (75fb0e4124)
1312 lines
38 KiB
C++
1312 lines
38 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
|
* 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 "proxy/ScriptedDirectProxyHandler.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "jsobjinlines.h"
|
|
#include "vm/NativeObject-inl.h"
|
|
|
|
#include "vm/NativeObject-inl.h"
|
|
|
|
using namespace js;
|
|
|
|
using JS::IsArrayAnswer;
|
|
using mozilla::ArrayLength;
|
|
|
|
static inline bool
|
|
IsDataDescriptor(const PropertyDescriptor& desc)
|
|
{
|
|
return desc.obj && !(desc.attrs & (JSPROP_GETTER | JSPROP_SETTER));
|
|
}
|
|
|
|
static inline bool
|
|
IsAccessorDescriptor(const PropertyDescriptor& desc)
|
|
{
|
|
return desc.obj && desc.attrs & (JSPROP_GETTER | JSPROP_SETTER);
|
|
}
|
|
|
|
// ES6 (5 April 2014) ValidateAndApplyPropertyDescriptor(O, P, Extensible, Desc, Current)
|
|
// Since we are actually performing 9.1.6.2 IsCompatiblePropertyDescriptor(Extensible, Desc,
|
|
// Current), some parameters are omitted.
|
|
static bool
|
|
ValidatePropertyDescriptor(JSContext* cx, bool extensible, Handle<PropertyDescriptor> desc,
|
|
Handle<PropertyDescriptor> current, bool* bp)
|
|
{
|
|
// step 2
|
|
if (!current.object()) {
|
|
// Since |O| is always undefined, substeps c and d fall away.
|
|
*bp = extensible;
|
|
return true;
|
|
}
|
|
|
|
// step 3
|
|
if (!desc.hasValue() && !desc.hasWritable() &&
|
|
!desc.hasGetterObject() && !desc.hasSetterObject() &&
|
|
!desc.hasEnumerable() && !desc.hasConfigurable())
|
|
{
|
|
*bp = true;
|
|
return true;
|
|
}
|
|
|
|
// step 4
|
|
if ((!desc.hasWritable() ||
|
|
(current.hasWritable() && desc.writable() == current.writable())) &&
|
|
(!desc.hasGetterObject() || desc.getter() == current.getter()) &&
|
|
(!desc.hasSetterObject() || desc.setter() == current.setter()) &&
|
|
(!desc.hasEnumerable() || desc.enumerable() == current.enumerable()) &&
|
|
(!desc.hasConfigurable() || desc.configurable() == current.configurable()))
|
|
{
|
|
if (!desc.hasValue()) {
|
|
*bp = true;
|
|
return true;
|
|
}
|
|
bool same = false;
|
|
if (!SameValue(cx, desc.value(), current.value(), &same))
|
|
return false;
|
|
if (same) {
|
|
*bp = true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// step 5
|
|
if (!current.configurable()) {
|
|
if (desc.hasConfigurable() && desc.configurable()) {
|
|
*bp = false;
|
|
return true;
|
|
}
|
|
|
|
if (desc.hasEnumerable() && desc.enumerable() != current.enumerable()) {
|
|
*bp = false;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// step 6
|
|
if (desc.isGenericDescriptor()) {
|
|
*bp = true;
|
|
return true;
|
|
}
|
|
|
|
// step 7a
|
|
if (current.isDataDescriptor() != desc.isDataDescriptor()) {
|
|
*bp = current.configurable();
|
|
return true;
|
|
}
|
|
|
|
// step 8
|
|
if (current.isDataDescriptor()) {
|
|
MOZ_ASSERT(desc.isDataDescriptor()); // by step 7a
|
|
if (!current.configurable() && !current.writable()) {
|
|
if (desc.hasWritable() && desc.writable()) {
|
|
*bp = false;
|
|
return true;
|
|
}
|
|
|
|
if (desc.hasValue()) {
|
|
bool same;
|
|
if (!SameValue(cx, desc.value(), current.value(), &same))
|
|
return false;
|
|
if (!same) {
|
|
*bp = false;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
*bp = true;
|
|
return true;
|
|
}
|
|
|
|
// step 9
|
|
MOZ_ASSERT(current.isAccessorDescriptor()); // by step 8
|
|
MOZ_ASSERT(desc.isAccessorDescriptor()); // by step 7a
|
|
*bp = (current.configurable() ||
|
|
((!desc.hasSetterObject() || desc.setter() == current.setter()) &&
|
|
(!desc.hasGetterObject() || desc.getter() == current.getter())));
|
|
return true;
|
|
}
|
|
|
|
// Get the [[ProxyHandler]] of a scripted direct proxy.
|
|
static JSObject*
|
|
GetDirectProxyHandlerObject(JSObject* proxy)
|
|
{
|
|
MOZ_ASSERT(proxy->as<ProxyObject>().handler() == &ScriptedDirectProxyHandler::singleton);
|
|
return proxy->as<ProxyObject>().extra(ScriptedDirectProxyHandler::HANDLER_EXTRA).toObjectOrNull();
|
|
}
|
|
|
|
static inline void
|
|
ReportInvalidTrapResult(JSContext* cx, JSObject* proxy, JSAtom* atom)
|
|
{
|
|
RootedValue v(cx, ObjectOrNullValue(proxy));
|
|
JSAutoByteString bytes;
|
|
if (!AtomToPrintableString(cx, atom, &bytes))
|
|
return;
|
|
ReportValueError2(cx, JSMSG_INVALID_TRAP_RESULT, JSDVG_IGNORE_STACK, v,
|
|
nullptr, bytes.ptr());
|
|
}
|
|
|
|
// ES6 implements both getPrototype and setPrototype traps. We don't have them yet (see bug
|
|
// 888969). For now, use these, to account for proxy revocation.
|
|
bool
|
|
ScriptedDirectProxyHandler::getPrototype(JSContext* cx, HandleObject proxy,
|
|
MutableHandleObject protop) const
|
|
{
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
// Though handler is used elsewhere, spec mandates that both get set to null.
|
|
if (!target) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
return GetPrototype(cx, target, protop);
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto,
|
|
ObjectOpResult& result) const
|
|
{
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
if (!target) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
return SetPrototype(cx, target, proto, result);
|
|
}
|
|
|
|
// Not yet part of ES6, but hopefully to be standards-tracked -- and needed to
|
|
// handle revoked proxies in any event.
|
|
bool
|
|
ScriptedDirectProxyHandler::setImmutablePrototype(JSContext* cx, HandleObject proxy,
|
|
bool* succeeded) const
|
|
{
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
if (!target) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
return SetImmutablePrototype(cx, target, succeeded);
|
|
}
|
|
|
|
// ES6 draft rev 32 (2 Feb 2015) 9.5.4 Proxy.[[PreventExtensions]]()
|
|
bool
|
|
ScriptedDirectProxyHandler::preventExtensions(JSContext* cx, HandleObject proxy,
|
|
ObjectOpResult& result) const
|
|
{
|
|
// Steps 1-3.
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// Step 4.
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// Steps 5-6.
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().preventExtensions, &trap))
|
|
return false;
|
|
|
|
// Step 7.
|
|
if (trap.isUndefined())
|
|
return PreventExtensions(cx, target, result);
|
|
|
|
// Steps 8-9.
|
|
Value argv[] = {
|
|
ObjectValue(*target)
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// Steps 10-11.
|
|
if (ToBoolean(trapResult)) {
|
|
bool extensible;
|
|
if (!IsExtensible(cx, target, &extensible))
|
|
return false;
|
|
if (extensible) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
|
|
JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE);
|
|
return false;
|
|
}
|
|
return result.succeed();
|
|
}
|
|
return result.fail(JSMSG_PROXY_PREVENTEXTENSIONS_RETURNED_FALSE);
|
|
}
|
|
|
|
// ES6 (5 April, 2014) 9.5.3 Proxy.[[IsExtensible]]()
|
|
bool
|
|
ScriptedDirectProxyHandler::isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const
|
|
{
|
|
// step 1
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 2
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 3
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// step 4-5
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().isExtensible, &trap))
|
|
return false;
|
|
|
|
// step 6
|
|
if (trap.isUndefined())
|
|
return IsExtensible(cx, target, extensible);
|
|
|
|
// step 7, 9
|
|
Value argv[] = {
|
|
ObjectValue(*target)
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 8
|
|
bool booleanTrapResult = ToBoolean(trapResult);
|
|
|
|
// step 10-11
|
|
bool targetResult;
|
|
if (!IsExtensible(cx, target, &targetResult))
|
|
return false;
|
|
|
|
// step 12
|
|
if (targetResult != booleanTrapResult) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_EXTENSIBILITY);
|
|
return false;
|
|
}
|
|
|
|
// step 13
|
|
*extensible = booleanTrapResult;
|
|
return true;
|
|
}
|
|
|
|
// ES6 (5 April 2014) 9.5.5 Proxy.[[GetOwnProperty]](P)
|
|
bool
|
|
ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
|
|
MutableHandle<PropertyDescriptor> desc) const
|
|
{
|
|
// step 2
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 3
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 4
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// step 5-6
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().getOwnPropertyDescriptor, &trap))
|
|
return false;
|
|
|
|
// step 7
|
|
if (trap.isUndefined())
|
|
return GetOwnPropertyDescriptor(cx, target, id, desc);
|
|
|
|
// step 8-9
|
|
RootedValue propKey(cx);
|
|
if (!IdToStringOrSymbol(cx, id, &propKey))
|
|
return false;
|
|
|
|
Value argv[] = {
|
|
ObjectValue(*target),
|
|
propKey
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 10
|
|
if (!trapResult.isUndefined() && !trapResult.isObject()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_GETOWN_OBJORUNDEF);
|
|
return false;
|
|
}
|
|
|
|
//step 11-12
|
|
Rooted<PropertyDescriptor> targetDesc(cx);
|
|
if (!GetOwnPropertyDescriptor(cx, target, id, &targetDesc))
|
|
return false;
|
|
|
|
// step 13
|
|
if (trapResult.isUndefined()) {
|
|
// substep a
|
|
if (!targetDesc.object()) {
|
|
desc.object().set(nullptr);
|
|
return true;
|
|
}
|
|
|
|
// substep b
|
|
if (!targetDesc.configurable()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE);
|
|
return false;
|
|
}
|
|
|
|
// substep c-e
|
|
bool extensibleTarget;
|
|
if (!IsExtensible(cx, target, &extensibleTarget))
|
|
return false;
|
|
if (!extensibleTarget) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE);
|
|
return false;
|
|
}
|
|
|
|
// substep f
|
|
desc.object().set(nullptr);
|
|
return true;
|
|
}
|
|
|
|
// step 14-15
|
|
bool extensibleTarget;
|
|
if (!IsExtensible(cx, target, &extensibleTarget))
|
|
return false;
|
|
|
|
// step 16-17
|
|
Rooted<PropertyDescriptor> resultDesc(cx);
|
|
if (!ToPropertyDescriptor(cx, trapResult, true, &resultDesc))
|
|
return false;
|
|
|
|
// step 18
|
|
CompletePropertyDescriptor(&resultDesc);
|
|
|
|
// step 19
|
|
bool valid;
|
|
if (!ValidatePropertyDescriptor(cx, extensibleTarget, resultDesc, targetDesc, &valid))
|
|
return false;
|
|
|
|
// step 20
|
|
if (!valid) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_INVALID);
|
|
return false;
|
|
}
|
|
|
|
// step 21
|
|
if (!resultDesc.configurable()) {
|
|
if (!targetDesc.object()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NE_AS_NC);
|
|
return false;
|
|
}
|
|
|
|
if (targetDesc.configurable()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_C_AS_NC);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// step 22
|
|
desc.set(resultDesc);
|
|
desc.object().set(proxy);
|
|
return true;
|
|
}
|
|
|
|
// ES6 draft rev 31 (15 Jan 2015) 9.5.6 Proxy.[[DefineOwnProperty]](P, Desc)
|
|
bool
|
|
ScriptedDirectProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, HandleId id,
|
|
Handle<PropertyDescriptor> desc,
|
|
ObjectOpResult& result) const
|
|
{
|
|
// steps 2-4
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 5
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// steps 6-7
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().defineProperty, &trap))
|
|
return false;
|
|
|
|
// step 8
|
|
if (trap.isUndefined())
|
|
return DefineProperty(cx, target, id, desc, result);
|
|
|
|
// step 9
|
|
RootedValue descObj(cx);
|
|
if (!FromPropertyDescriptorToObject(cx, desc, &descObj))
|
|
return false;
|
|
|
|
// steps 10-11
|
|
RootedValue propKey(cx);
|
|
if (!IdToStringOrSymbol(cx, id, &propKey))
|
|
return false;
|
|
|
|
Value argv[] = {
|
|
ObjectValue(*target),
|
|
propKey,
|
|
descObj
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 12
|
|
if (!ToBoolean(trapResult))
|
|
return result.fail(JSMSG_PROXY_DEFINE_RETURNED_FALSE);
|
|
|
|
// step 13-14
|
|
Rooted<PropertyDescriptor> targetDesc(cx);
|
|
if (!GetOwnPropertyDescriptor(cx, target, id, &targetDesc))
|
|
return false;
|
|
|
|
// step 15-16
|
|
bool extensibleTarget;
|
|
if (!IsExtensible(cx, target, &extensibleTarget))
|
|
return false;
|
|
|
|
// step 17-18
|
|
bool settingConfigFalse = desc.hasConfigurable() && !desc.configurable();
|
|
if (!targetDesc.object()) {
|
|
// step 19.a
|
|
if (!extensibleTarget) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_NEW);
|
|
return false;
|
|
}
|
|
// step 19.b
|
|
if (settingConfigFalse) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_NE_AS_NC);
|
|
return false;
|
|
}
|
|
} else {
|
|
// step 20
|
|
bool valid;
|
|
if (!ValidatePropertyDescriptor(cx, extensibleTarget, desc, targetDesc, &valid))
|
|
return false;
|
|
if (!valid || (settingConfigFalse && targetDesc.configurable())) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_INVALID);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// step 21
|
|
return result.succeed();
|
|
}
|
|
|
|
// ES6 7.3.17 But elementTypes is is fixed to symbol/string.
|
|
static bool
|
|
CreateFilteredListFromArrayLike(JSContext* cx, HandleValue v, AutoIdVector& props)
|
|
{
|
|
// Step 3.
|
|
RootedObject obj(cx, NonNullObject(cx, v));
|
|
if (!obj)
|
|
return false;
|
|
|
|
// Steps 4-5.
|
|
uint32_t len;
|
|
if (!GetLengthProperty(cx, obj, &len))
|
|
return false;
|
|
|
|
// Steps 6-8.
|
|
RootedValue next(cx);
|
|
RootedId id(cx);
|
|
for (uint32_t index = 0; index < len; index++) {
|
|
if (!GetElement(cx, obj, obj, index, &next))
|
|
return false;
|
|
|
|
if (!next.isString() && !next.isSymbol()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ONWKEYS_STR_SYM);
|
|
return false;
|
|
}
|
|
|
|
// Unobservable for strings/symbols.
|
|
if (!ValueToId<CanGC>(cx, next, &id))
|
|
return false;
|
|
|
|
if (!props.append(id))
|
|
return false;
|
|
}
|
|
|
|
// Step 9.
|
|
return true;
|
|
}
|
|
|
|
|
|
// ES6 9.5.12 Proxy.[[OwnPropertyKeys]]()
|
|
bool
|
|
ScriptedDirectProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy,
|
|
AutoIdVector& props) const
|
|
{
|
|
// Step 1.
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// Step 2.
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
// Step 3. Superfluous assertion.
|
|
|
|
// Step 4.
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// Steps 5-6.
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().ownKeys, &trap))
|
|
return false;
|
|
|
|
// Step 7.
|
|
if (trap.isUndefined())
|
|
return GetPropertyKeys(cx, target, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, &props);
|
|
|
|
// Step 8.
|
|
Value argv[] = {
|
|
ObjectValue(*target)
|
|
};
|
|
RootedValue trapResultArray(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResultArray))
|
|
return false;
|
|
|
|
// Steps 9-10.
|
|
AutoIdVector trapResult(cx);
|
|
if (!CreateFilteredListFromArrayLike(cx, trapResultArray, trapResult))
|
|
return false;
|
|
|
|
// Steps 11-12.
|
|
bool extensibleTarget;
|
|
if (!IsExtensible(cx, target, &extensibleTarget))
|
|
return false;
|
|
|
|
// Steps 13-14.
|
|
AutoIdVector targetKeys(cx);
|
|
if (!GetPropertyKeys(cx, target, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, &targetKeys))
|
|
return false;
|
|
|
|
// Step 15. Superfluous assertion.
|
|
|
|
// Steps 16-17.
|
|
AutoIdVector targetConfigurableKeys(cx);
|
|
AutoIdVector targetNonconfigurableKeys(cx);
|
|
|
|
// Step 18.
|
|
Rooted<PropertyDescriptor> desc(cx);
|
|
for (size_t i = 0; i < targetKeys.length(); ++i) {
|
|
// Steps a-b.
|
|
if (!GetOwnPropertyDescriptor(cx, target, targetKeys[i], &desc))
|
|
return false;
|
|
|
|
// Steps c-d.
|
|
if (desc.object() && !desc.configurable()) {
|
|
if (!targetNonconfigurableKeys.append(targetKeys[i]))
|
|
return false;
|
|
} else {
|
|
if (!targetConfigurableKeys.append(targetKeys[i]))
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Step 19.
|
|
if (extensibleTarget && targetNonconfigurableKeys.empty())
|
|
return props.appendAll(trapResult);
|
|
|
|
// Step 20.
|
|
AutoIdVector uncheckedResultKeys(cx);
|
|
if (!uncheckedResultKeys.appendAll(trapResult))
|
|
return false;
|
|
|
|
// Step 21.
|
|
for (size_t i = 0; i < targetNonconfigurableKeys.length(); ++i) {
|
|
RootedId key(cx, targetNonconfigurableKeys[i]);
|
|
MOZ_ASSERT(key != JSID_VOID);
|
|
|
|
bool found = false;
|
|
for (size_t j = 0; j < uncheckedResultKeys.length(); ++j) {
|
|
if (key == uncheckedResultKeys[j]) {
|
|
uncheckedResultKeys[j].set(JSID_VOID);
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!found) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SKIP_NC);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Step 22.
|
|
if (extensibleTarget)
|
|
return props.appendAll(trapResult);
|
|
|
|
// Step 23.
|
|
for (size_t i = 0; i < targetConfigurableKeys.length(); ++i) {
|
|
RootedId key(cx, targetConfigurableKeys[i]);
|
|
MOZ_ASSERT(key != JSID_VOID);
|
|
|
|
bool found = false;
|
|
for (size_t j = 0; j < uncheckedResultKeys.length(); ++j) {
|
|
if (key == uncheckedResultKeys[j]) {
|
|
uncheckedResultKeys[j].set(JSID_VOID);
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!found) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Step 24.
|
|
for (size_t i = 0; i < uncheckedResultKeys.length(); ++i) {
|
|
if (uncheckedResultKeys[i].get() != JSID_VOID) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NEW);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Step 25.
|
|
return props.appendAll(trapResult);
|
|
}
|
|
|
|
// ES6 draft rev 32 (2 Feb 2014) 9.5.10 Proxy.[[Delete]](P)
|
|
bool
|
|
ScriptedDirectProxyHandler::delete_(JSContext* cx, HandleObject proxy, HandleId id,
|
|
ObjectOpResult& result) const
|
|
{
|
|
// step 2
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 3
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// steps 4-5
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// steps 6-7
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().deleteProperty, &trap))
|
|
return false;
|
|
|
|
// step 8
|
|
if (trap.isUndefined())
|
|
return DeleteProperty(cx, target, id, result);
|
|
|
|
// steps 9-10
|
|
RootedValue value(cx);
|
|
if (!IdToStringOrSymbol(cx, id, &value))
|
|
return false;
|
|
Value argv[] = {
|
|
ObjectValue(*target),
|
|
value
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 11
|
|
if (!ToBoolean(trapResult))
|
|
return result.fail(JSMSG_PROXY_DELETE_RETURNED_FALSE);
|
|
|
|
// steps 12-13
|
|
Rooted<PropertyDescriptor> desc(cx);
|
|
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
|
return false;
|
|
|
|
// step 14-15
|
|
if (desc.object() && !desc.configurable()) {
|
|
RootedValue v(cx, IdToValue(id));
|
|
ReportValueError(cx, JSMSG_CANT_DELETE, JSDVG_IGNORE_STACK, v, nullptr);
|
|
return false;
|
|
}
|
|
|
|
// step 16
|
|
return result.succeed();
|
|
}
|
|
|
|
// ES6 (14 October, 2014) 9.5.11 Proxy.[[Enumerate]]
|
|
bool
|
|
ScriptedDirectProxyHandler::enumerate(JSContext* cx, HandleObject proxy,
|
|
MutableHandleObject objp) const
|
|
{
|
|
// step 1
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 2
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 3: unnecessary assert
|
|
// step 4
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// step 5-6
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().enumerate, &trap))
|
|
return false;
|
|
|
|
// step 7
|
|
if (trap.isUndefined())
|
|
return GetIterator(cx, target, 0, objp);
|
|
|
|
// step 8-9
|
|
Value argv[] = {
|
|
ObjectOrNullValue(target)
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 10
|
|
if (trapResult.isPrimitive()) {
|
|
ReportInvalidTrapResult(cx, proxy, cx->names().enumerate);
|
|
return false;
|
|
}
|
|
|
|
// step 11
|
|
objp.set(&trapResult.toObject());
|
|
return true;
|
|
}
|
|
|
|
// ES6 (22 May, 2014) 9.5.7 Proxy.[[HasProperty]](P)
|
|
bool
|
|
ScriptedDirectProxyHandler::has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const
|
|
{
|
|
// step 2
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 3
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 4
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// step 5-6
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().has, &trap))
|
|
return false;
|
|
|
|
// step 7
|
|
if (trap.isUndefined())
|
|
return HasProperty(cx, target, id, bp);
|
|
|
|
// step 8,10
|
|
RootedValue value(cx);
|
|
if (!IdToStringOrSymbol(cx, id, &value))
|
|
return false;
|
|
Value argv[] = {
|
|
ObjectOrNullValue(target),
|
|
value
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 9
|
|
bool success = ToBoolean(trapResult);
|
|
|
|
// step 11
|
|
if (!success) {
|
|
Rooted<PropertyDescriptor> desc(cx);
|
|
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
|
return false;
|
|
|
|
if (desc.object()) {
|
|
if (!desc.configurable()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE);
|
|
return false;
|
|
}
|
|
|
|
bool extensible;
|
|
if (!IsExtensible(cx, target, &extensible))
|
|
return false;
|
|
if (!extensible) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// step 12
|
|
*bp = success;
|
|
return true;
|
|
}
|
|
|
|
// ES6 (22 May, 2014) 9.5.8 Proxy.[[GetP]](P, Receiver)
|
|
bool
|
|
ScriptedDirectProxyHandler::get(JSContext* cx, HandleObject proxy, HandleValue receiver,
|
|
HandleId id, MutableHandleValue vp) const
|
|
{
|
|
// step 2
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 3
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 4
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
|
|
// step 5-6
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().get, &trap))
|
|
return false;
|
|
|
|
// step 7
|
|
if (trap.isUndefined())
|
|
return GetProperty(cx, target, receiver, id, vp);
|
|
|
|
// step 8-9
|
|
RootedValue value(cx);
|
|
if (!IdToStringOrSymbol(cx, id, &value))
|
|
return false;
|
|
Value argv[] = {
|
|
ObjectOrNullValue(target),
|
|
value,
|
|
receiver
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 10-11
|
|
Rooted<PropertyDescriptor> desc(cx);
|
|
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
|
return false;
|
|
|
|
// step 12
|
|
if (desc.object()) {
|
|
if (desc.isDataDescriptor() && !desc.configurable() && !desc.writable()) {
|
|
bool same;
|
|
if (!SameValue(cx, trapResult, desc.value(), &same))
|
|
return false;
|
|
if (!same) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MUST_REPORT_SAME_VALUE);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (desc.isAccessorDescriptor() && !desc.configurable() && desc.getterObject() == nullptr) {
|
|
if (!trapResult.isUndefined()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MUST_REPORT_UNDEFINED);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// step 13
|
|
vp.set(trapResult);
|
|
return true;
|
|
}
|
|
|
|
// ES6 draft rev 32 (2015 Feb 2) 9.5.9 Proxy.[[Set]](P, V, Receiver)
|
|
bool
|
|
ScriptedDirectProxyHandler::set(JSContext* cx, HandleObject proxy, HandleId id, HandleValue v,
|
|
HandleValue receiver, ObjectOpResult& result) const
|
|
{
|
|
// step 2-3 (Steps 1 and 4 are irrelevant assertions.)
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 5-7
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().set, &trap))
|
|
return false;
|
|
|
|
// step 8
|
|
if (trap.isUndefined())
|
|
return SetProperty(cx, target, id, v, receiver, result);
|
|
|
|
// step 9-10
|
|
RootedValue value(cx);
|
|
if (!IdToStringOrSymbol(cx, id, &value))
|
|
return false;
|
|
Value argv[] = {
|
|
ObjectOrNullValue(target),
|
|
value,
|
|
v.get(),
|
|
receiver.get()
|
|
};
|
|
RootedValue trapResult(cx);
|
|
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
|
|
return false;
|
|
|
|
// step 11
|
|
if (!ToBoolean(trapResult))
|
|
return result.fail(JSMSG_PROXY_SET_RETURNED_FALSE);
|
|
|
|
// step 12-13
|
|
Rooted<PropertyDescriptor> desc(cx);
|
|
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
|
return false;
|
|
|
|
// step 14
|
|
if (desc.object()) {
|
|
if (desc.isDataDescriptor() && !desc.configurable() && !desc.writable()) {
|
|
bool same;
|
|
if (!SameValue(cx, v, desc.value(), &same))
|
|
return false;
|
|
if (!same) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_NW_NC);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (desc.isAccessorDescriptor() && !desc.configurable() && desc.setterObject() == nullptr) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_WO_SETTER);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// step 15
|
|
return result.succeed();
|
|
}
|
|
|
|
// ES6 (22 May, 2014) 9.5.13 Proxy.[[Call]]
|
|
bool
|
|
ScriptedDirectProxyHandler::call(JSContext* cx, HandleObject proxy, const CallArgs& args) const
|
|
{
|
|
// step 1
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 2
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 3
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
MOZ_ASSERT(target->isCallable());
|
|
|
|
// step 7
|
|
RootedObject argsArray(cx, NewDenseCopiedArray(cx, args.length(), args.array()));
|
|
if (!argsArray)
|
|
return false;
|
|
|
|
// step 4-5
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().apply, &trap))
|
|
return false;
|
|
|
|
// step 6
|
|
if (trap.isUndefined()) {
|
|
RootedValue targetv(cx, ObjectValue(*target));
|
|
return Invoke(cx, args.thisv(), targetv, args.length(), args.array(), args.rval());
|
|
}
|
|
|
|
// step 8
|
|
Value argv[] = {
|
|
ObjectValue(*target),
|
|
args.thisv(),
|
|
ObjectValue(*argsArray)
|
|
};
|
|
RootedValue thisValue(cx, ObjectValue(*handler));
|
|
return Invoke(cx, thisValue, trap, ArrayLength(argv), argv, args.rval());
|
|
}
|
|
|
|
// ES6 (22 May, 2014) 9.5.14 Proxy.[[Construct]]
|
|
bool
|
|
ScriptedDirectProxyHandler::construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const
|
|
{
|
|
// step 1
|
|
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
|
|
|
|
// step 2
|
|
if (!handler) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
// step 3
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
MOZ_ASSERT(target->isConstructor());
|
|
|
|
// step 7
|
|
RootedObject argsArray(cx, NewDenseCopiedArray(cx, args.length(), args.array()));
|
|
if (!argsArray)
|
|
return false;
|
|
|
|
// step 4-5
|
|
RootedValue trap(cx);
|
|
if (!GetProperty(cx, handler, handler, cx->names().construct, &trap))
|
|
return false;
|
|
|
|
// step 6
|
|
if (trap.isUndefined()) {
|
|
ConstructArgs cargs(cx);
|
|
if (!FillArgumentsFromArraylike(cx, cargs, args))
|
|
return false;
|
|
|
|
RootedValue targetv(cx, ObjectValue(*target));
|
|
RootedObject obj(cx);
|
|
if (!Construct(cx, targetv, cargs, args.newTarget(), &obj))
|
|
return false;
|
|
|
|
args.rval().setObject(*obj);
|
|
return true;
|
|
}
|
|
|
|
// step 8-9
|
|
Value constructArgv[] = {
|
|
ObjectValue(*target),
|
|
ObjectValue(*argsArray),
|
|
args.newTarget()
|
|
};
|
|
RootedValue thisValue(cx, ObjectValue(*handler));
|
|
if (!Invoke(cx, thisValue, trap, ArrayLength(constructArgv), constructArgv, args.rval()))
|
|
return false;
|
|
|
|
// step 10
|
|
if (!args.rval().isObject()) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_CONSTRUCT_OBJECT);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
|
|
const CallArgs& args) const
|
|
{
|
|
ReportIncompatible(cx, args);
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
|
|
bool* bp) const
|
|
{
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
if (!target) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
|
|
return false;
|
|
}
|
|
|
|
return HasInstance(cx, target, v, bp);
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::getBuiltinClass(JSContext* cx, HandleObject proxy,
|
|
ESClassValue* classValue) const
|
|
{
|
|
*classValue = ESClass_Other;
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::isArray(JSContext* cx, HandleObject proxy,
|
|
IsArrayAnswer* answer) const
|
|
{
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
if (target)
|
|
return JS::IsArray(cx, target, answer);
|
|
|
|
*answer = IsArrayAnswer::RevokedProxy;
|
|
return true;
|
|
}
|
|
|
|
const char*
|
|
ScriptedDirectProxyHandler::className(JSContext* cx, HandleObject proxy) const
|
|
{
|
|
// Right now the caller is not prepared to handle failures.
|
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
|
if (!target)
|
|
return BaseProxyHandler::className(cx, proxy);
|
|
|
|
return GetObjectClassName(cx, target);
|
|
}
|
|
JSString*
|
|
ScriptedDirectProxyHandler::fun_toString(JSContext* cx, HandleObject proxy,
|
|
unsigned indent) const
|
|
{
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
|
|
js_Function_str, js_toString_str, "object");
|
|
return nullptr;
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::regexp_toShared(JSContext* cx, HandleObject proxy,
|
|
RegExpGuard* g) const
|
|
{
|
|
MOZ_CRASH("Should not end up in ScriptedDirectProxyHandler::regexp_toShared");
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::boxedValue_unbox(JSContext* cx, HandleObject proxy,
|
|
MutableHandleValue vp) const
|
|
{
|
|
MOZ_CRASH("Should not end up in ScriptedDirectProxyHandler::boxedValue_unbox");
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::isCallable(JSObject* obj) const
|
|
{
|
|
MOZ_ASSERT(obj->as<ProxyObject>().handler() == &ScriptedDirectProxyHandler::singleton);
|
|
uint32_t callConstruct = obj->as<ProxyObject>().extra(IS_CALLCONSTRUCT_EXTRA).toPrivateUint32();
|
|
return !!(callConstruct & IS_CALLABLE);
|
|
}
|
|
|
|
bool
|
|
ScriptedDirectProxyHandler::isConstructor(JSObject* obj) const
|
|
{
|
|
MOZ_ASSERT(obj->as<ProxyObject>().handler() == &ScriptedDirectProxyHandler::singleton);
|
|
uint32_t callConstruct = obj->as<ProxyObject>().extra(IS_CALLCONSTRUCT_EXTRA).toPrivateUint32();
|
|
return !!(callConstruct & IS_CONSTRUCTOR);
|
|
}
|
|
|
|
const char ScriptedDirectProxyHandler::family = 0;
|
|
const ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton;
|
|
|
|
bool
|
|
IsRevokedScriptedProxy(JSObject* obj)
|
|
{
|
|
obj = CheckedUnwrap(obj);
|
|
return obj && IsScriptedProxy(obj) && !obj->as<ProxyObject>().target();
|
|
}
|
|
|
|
// ES6 draft rc4 9.5.15.
|
|
static bool
|
|
NewScriptedProxy(JSContext* cx, CallArgs& args, const char* callerName)
|
|
{
|
|
if (args.length() < 2) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
|
|
callerName, "1", "s");
|
|
return false;
|
|
}
|
|
|
|
// Step 1.
|
|
RootedObject target(cx, NonNullObject(cx, args[0]));
|
|
if (!target)
|
|
return false;
|
|
|
|
// Step 2.
|
|
if (IsRevokedScriptedProxy(target)) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_ARG_REVOKED, "1");
|
|
return false;
|
|
}
|
|
|
|
// Step 3.
|
|
RootedObject handler(cx, NonNullObject(cx, args[1]));
|
|
if (!handler)
|
|
return false;
|
|
|
|
// Step 4.
|
|
if (IsRevokedScriptedProxy(handler)) {
|
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_ARG_REVOKED, "2");
|
|
return false;
|
|
}
|
|
|
|
// Steps 5-6, and 8 (reordered).
|
|
RootedValue priv(cx, ObjectValue(*target));
|
|
JSObject* proxy_ =
|
|
NewProxyObject(cx, &ScriptedDirectProxyHandler::singleton,
|
|
priv, TaggedProto::LazyProto);
|
|
if (!proxy_)
|
|
return false;
|
|
|
|
// Step 9 (reordered).
|
|
Rooted<ProxyObject*> proxy(cx, &proxy_->as<ProxyObject>());
|
|
proxy->setExtra(ScriptedDirectProxyHandler::HANDLER_EXTRA, ObjectValue(*handler));
|
|
|
|
// Step 7, Assign [[Call]] and [[Construct]].
|
|
uint32_t callable = target->isCallable() ? ScriptedDirectProxyHandler::IS_CALLABLE : 0;
|
|
uint32_t constructor = target->isConstructor() ? ScriptedDirectProxyHandler::IS_CONSTRUCTOR : 0;
|
|
proxy->as<ProxyObject>().setExtra(ScriptedDirectProxyHandler::IS_CALLCONSTRUCT_EXTRA,
|
|
PrivateUint32Value(callable | constructor));
|
|
|
|
// Step 10.
|
|
args.rval().setObject(*proxy);
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
js::proxy(JSContext* cx, unsigned argc, Value* vp)
|
|
{
|
|
CallArgs args = CallArgsFromVp(argc, vp);
|
|
|
|
if (!ThrowIfNotConstructing(cx, args, "Proxy"))
|
|
return false;
|
|
|
|
return NewScriptedProxy(cx, args, "Proxy");
|
|
}
|
|
|
|
static bool
|
|
RevokeProxy(JSContext* cx, unsigned argc, Value* vp)
|
|
{
|
|
CallReceiver rec = CallReceiverFromVp(vp);
|
|
|
|
RootedFunction func(cx, &rec.callee().as<JSFunction>());
|
|
RootedObject p(cx, func->getExtendedSlot(ScriptedDirectProxyHandler::REVOKE_SLOT).toObjectOrNull());
|
|
|
|
if (p) {
|
|
func->setExtendedSlot(ScriptedDirectProxyHandler::REVOKE_SLOT, NullValue());
|
|
|
|
MOZ_ASSERT(p->is<ProxyObject>());
|
|
|
|
p->as<ProxyObject>().setSameCompartmentPrivate(NullValue());
|
|
p->as<ProxyObject>().setExtra(ScriptedDirectProxyHandler::HANDLER_EXTRA, NullValue());
|
|
}
|
|
|
|
rec.rval().setUndefined();
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
js::proxy_revocable(JSContext* cx, unsigned argc, Value* vp)
|
|
{
|
|
CallArgs args = CallArgsFromVp(argc, vp);
|
|
|
|
if (!NewScriptedProxy(cx, args, "Proxy.revocable"))
|
|
return false;
|
|
|
|
RootedValue proxyVal(cx, args.rval());
|
|
MOZ_ASSERT(proxyVal.toObject().is<ProxyObject>());
|
|
|
|
RootedObject revoker(cx, NewFunctionByIdWithReserved(cx, RevokeProxy, 0, 0,
|
|
AtomToId(cx->names().revoke)));
|
|
if (!revoker)
|
|
return false;
|
|
|
|
revoker->as<JSFunction>().initExtendedSlot(ScriptedDirectProxyHandler::REVOKE_SLOT, proxyVal);
|
|
|
|
RootedPlainObject result(cx, NewBuiltinClassInstance<PlainObject>(cx));
|
|
if (!result)
|
|
return false;
|
|
|
|
RootedValue revokeVal(cx, ObjectValue(*revoker));
|
|
if (!DefineProperty(cx, result, cx->names().proxy, proxyVal) ||
|
|
!DefineProperty(cx, result, cx->names().revoke, revokeVal))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
args.rval().setObject(*result);
|
|
return true;
|
|
}
|