Граф коммитов

150 Коммитов

Автор SHA1 Сообщение Дата
Kris Maglione a71c8e64ff Bug 1588839 - Part 1 - Add helper to allow structured cloning Error/Exception objects. r=bzbarsky
In order to be able to reasonably debug error results from things like
JSWindowActor.sendQuery, we need to be able to clone errors across process
boundaries, so that they can be propagated to the caller that initiated a
query. The standard for the structured clone algorithm does not allow cloning
errors directly, so this patch instead adds a chrome-only wrapper object which
supports structured clone writing, and on reading, automatically decodes to
the error object it wraps. Callers who wish to clone an Error or Exception
object simply need to wrap it in a ClonedErrorHolder before sending.

Differential Revision: https://phabricator.services.mozilla.com/D50881

--HG--
extra : moz-landing-system : lando
2019-12-07 18:59:14 +00:00
Ciure Andrei cbb1fe8008 Backed out 4 changesets (bug 1588839) for causing JSWindowActor.cpp failures CLOSED TREE
Backed out changeset 7cfcd0f5da4f (bug 1588839)
Backed out changeset cde41501372a (bug 1588839)
Backed out changeset 65cc1910918c (bug 1588839)
Backed out changeset 2f8b5b48c896 (bug 1588839)
2019-12-07 19:41:36 +02:00
Kris Maglione 32678cd302 Bug 1588839 - Part 1 - Add helper to allow structured cloning Error/Exception objects. r=bzbarsky
In order to be able to reasonably debug error results from things like
JSWindowActor.sendQuery, we need to be able to clone errors across process
boundaries, so that they can be propagated to the caller that initiated a
query. The standard for the structured clone algorithm does not allow cloning
errors directly, so this patch instead adds a chrome-only wrapper object which
supports structured clone writing, and on reading, automatically decodes to
the error object it wraps. Callers who wish to clone an Error or Exception
object simply need to wrap it in a ClonedErrorHolder before sending.

Differential Revision: https://phabricator.services.mozilla.com/D50881

--HG--
extra : moz-landing-system : lando
2019-12-07 04:43:24 +00:00
Sylvestre Ledru 4aa92e3091 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D22514
2019-03-13 10:19:06 +01:00
Brian Hackett 89247ca139 Bug 1447244 Part 5 - Add source ID to nsIScriptError and ConsoleEvent, r=smaug.
--HG--
extra : rebase_source : df10848e2b61bcff4837602567d518e4b1e316fb
2019-01-16 12:00:38 -10:00
Boris Zbarsky 7e5a37a024 Bug 1521907 part 3. Start using CheckedUnwrapStatic/Dynamic in bindings. r=peterv
The basic idea for the changes around UnwrapObjectInternal and its callers
(UnwrapObject, UNWRAP_OBJECT, etc) is to add a parameter to the guts of the
object-unwrapping code in bindings which can be either a JSContext* or nullptr
(statically typed).  Then we test which type it is and do either a
CheckedUnwrapDynamic or CheckedUnwrapStatic.  Since the type is known at
compile time, there is no actual runtime check; the compiler just emits a call
to the right thing directly (verified by examining the assembly output on
Linux).

The rest of the changes are mostly propagating through that template parameter,
adding static asserts to make sure people don't accidentally pass nullptr while
trying to unwrap to a type that might be a WindowProxy or Location, etc.

There are also some changes to places that were calling CheckedUnwrap directly
to use either the static or dynamic version, as needed.

Differential Revision: https://phabricator.services.mozilla.com/D17883

--HG--
extra : moz-landing-system : lando
2019-02-02 03:23:49 +00:00
Gurzau Raul 44e4d42e8a Backed out 7 changesets (bug 1521907) for failing at unit/test_bug1151385.js on a CLOSED TREE.
Backed out changeset ef04359ccf0d (bug 1521907)
Backed out changeset ac1c61bf61e9 (bug 1521907)
Backed out changeset df09b7be63c5 (bug 1521907)
Backed out changeset 585fa0024d46 (bug 1521907)
Backed out changeset e593c29aaff4 (bug 1521907)
Backed out changeset ac2e180a35b6 (bug 1521907)
Backed out changeset 270b1db9ea81 (bug 1521907)
2019-02-02 00:58:16 +02:00
Boris Zbarsky d061930645 Bug 1521907 part 3. Start using CheckedUnwrapStatic/Dynamic in bindings. r=peterv
The basic idea for the changes around UnwrapObjectInternal and its callers
(UnwrapObject, UNWRAP_OBJECT, etc) is to add a parameter to the guts of the
object-unwrapping code in bindings which can be either a JSContext* or nullptr
(statically typed).  Then we test which type it is and do either a
CheckedUnwrapDynamic or CheckedUnwrapStatic.  Since the type is known at
compile time, there is no actual runtime check; the compiler just emits a call
to the right thing directly (verified by examining the assembly output on
Linux).

The rest of the changes are mostly propagating through that template parameter,
adding static asserts to make sure people don't accidentally pass nullptr while
trying to unwrap to a type that might be a WindowProxy or Location, etc.

There are also some changes to places that were calling CheckedUnwrap directly
to use either the static or dynamic version, as needed.

Differential Revision: https://phabricator.services.mozilla.com/D17883

--HG--
extra : moz-landing-system : lando
2019-02-01 18:48:13 +00:00
Ciure Andrei 63b0f3f854 Backed out 7 changesets (bug 1521907) for JSObject Wrapper.cpp bustages and failures CLOSED TREE
Backed out changeset ce3108090e77 (bug 1521907)
Backed out changeset efd05f4979f1 (bug 1521907)
Backed out changeset 2d0895148907 (bug 1521907)
Backed out changeset 192152fe986a (bug 1521907)
Backed out changeset ca65b46b0d37 (bug 1521907)
Backed out changeset b3daf5ca3d11 (bug 1521907)
Backed out changeset 1b0a09a46c70 (bug 1521907)
2019-02-01 19:38:25 +02:00
Boris Zbarsky a3784f4489 Bug 1521907 part 3. Start using CheckedUnwrapStatic/Dynamic in bindings. r=peterv
The basic idea for the changes around UnwrapObjectInternal and its callers
(UnwrapObject, UNWRAP_OBJECT, etc) is to add a parameter to the guts of the
object-unwrapping code in bindings which can be either a JSContext* or nullptr
(statically typed).  Then we test which type it is and do either a
CheckedUnwrapDynamic or CheckedUnwrapStatic.  Since the type is known at
compile time, there is no actual runtime check; the compiler just emits a call
to the right thing directly (verified by examining the assembly output on
Linux).

The rest of the changes are mostly propagating through that template parameter,
adding static asserts to make sure people don't accidentally pass nullptr while
trying to unwrap to a type that might be a WindowProxy or Location, etc.

There are also some changes to places that were calling CheckedUnwrap directly
to use either the static or dynamic version, as needed.

Differential Revision: https://phabricator.services.mozilla.com/D17883

--HG--
extra : moz-landing-system : lando
2019-01-31 15:50:06 +00:00
Andrew McCreight 0507792161 Bug 1471989 - Clear JSStackFrame's JS object pointer when the window goes away. r=bzbarsky
JSStackFrames are C++ objects that are exposed to chrome JS and keep
alive content JS. This means that if chrome JS leaks a stack frame
then a window can be leaked.

The basic idea of this patch is to think of JSStackFrames as
cross-compartment wrappers, and do a "hueyfix" on them by dropping the
content JS reference when the associated content window is closed.

To do that, this patch modifies the realm private to keep a list of
all live JSStackFrames that have been created with objects in that
realm. When we nuke that realm, we also clear out all of the JS
pointers from the registered stack frames on that realm.

This adds a hash table lookup to the JSStackFrame ctor and dtor, which
is hopefully not too much overhead.

The test works by intentionally leaking a JSStackFrame from chrome JS
and making sure that the window still goes away.

Differential Revision: https://phabricator.services.mozilla.com/D14880

--HG--
extra : moz-landing-system : lando
2018-12-19 19:42:04 +00:00
Andreea Pavel f9260c6914 Backed out changeset b1fe3750580d (bug 1471989) for build bustages on a CLOSED TREE 2018-12-19 20:48:10 +02:00
Andrew McCreight 09534362bf Bug 1471989 - Clear JSStackFrame's JS object pointer when the window goes away. r=bzbarsky
JSStackFrames are C++ objects that are exposed to chrome JS and keep
alive content JS. This means that if chrome JS leaks a stack frame
then a window can be leaked.

The basic idea of this patch is to think of JSStackFrames as
cross-compartment wrappers, and do a "hueyfix" on them by dropping the
content JS reference when the associated content window is closed.

To do that, this patch modifies the realm private to keep a list of
all live JSStackFrames that have been created with objects in that
realm. When we nuke that realm, we also clear out all of the JS
pointers from the registered stack frames on that realm.

This adds a hash table lookup to the JSStackFrame ctor and dtor, which
is hopefully not too much overhead.

The test works by intentionally leaking a JSStackFrame from chrome JS
and making sure that the window still goes away.

Differential Revision: https://phabricator.services.mozilla.com/D14880

--HG--
extra : moz-landing-system : lando
2018-12-19 16:46:25 +00:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Jeff Walden 3e90595274 Bug 1484389 - Move various SavedFrame-related functions and data types into js/public/SavedFrameAPI.h so that users aren't forced to depend on jsapi.h or jsfriendapi.h for them. r=jandem
--HG--
extra : rebase_source : d891f81cb0827d3c03971f71ba95a014d1e35379
2018-08-20 07:45:44 -07:00
Jan de Mooij 30d5135f62 Bug 1475559 part 6 - Add principals argument to SavedFrame APIs and do frame filtering based on it. r=bz
This removes AutoMaybeEnterFrameRealm. Most places pass cx->realm->principals: it preserves behavior when the (possibly wrapped) SavedFrame and cx are same-compartment. The main exception is the JSStackFrame DOM bindings code where we have to be a bit smarter about which principals to use.
2018-07-21 14:34:58 +02:00
Jan de Mooij 3536a9cbcb Bug 1475559 part 3 - Add JS::IsUnwrappedSavedFrame and assert this in JSStackFrame's constructor. r=bz 2018-07-21 14:33:22 +02:00
Emilio Cobos Álvarez fffb25b74f Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
This was done automatically replacing:

  s/mozilla::Move/std::move/
  s/ Move(/ std::move(/
  s/(Move(/(std::move(/

Removing the 'using mozilla::Move;' lines.

And then with a few manual fixups, see the bug for the split series..

MozReview-Commit-ID: Jxze3adipUh
2018-06-01 10:45:27 +02:00
Jan de Mooij 09c4068fa0 Bug 1464134 part 1 - Fix various places to use Realm instead of JSCompartment. r=luke 2018-05-31 11:28:48 +02:00
Karl Tomlinson 2405fe930c bug 1328964 use nsContentUtils::GetCurrentJSContext() on all threads r=smaug
nsContentUtils::GetCurrentJSContextForThread() originally needed to use
workers::GetCurrentThreadJSContext() in
https://hg.mozilla.org/mozilla-central/rev/366a45b41539#l2.18
because CycleCollectedJS*()->Context() did not exist until
https://hg.mozilla.org/mozilla-central/rev/1a0cd542e1e9#l7.12

nsContentUtils::GetCurrentJSContext() is thread-safe since these changes:
https://hg.mozilla.org/mozilla-central/rev/e636c7186286#l3.12
https://hg.mozilla.org/mozilla-central/rev/c8029c072776#l2.12

MozReview-Commit-ID: 2f1eGS9uBBO

--HG--
extra : rebase_source : dad1d2084a63413c3975f9e7c66c6b06857c9f23
2018-04-09 12:11:18 +12:00
Jason Orendorff e7c94fff59 Bug 1439063 - Part 1: Move several public headers from js/src to js/public. r=jandem.
js/src/jsalloc.h -> js/public/AllocPolicy.h
jsalloc.cpp -> js/src/util/AllocPolicy.cpp
jsbytecode.h -> merge into js/public/TypeDecls.h
jsprf.h -> js/public/Printf.h
jsprf.cpp -> js/src/util/Printf.cpp
jsprototypes.h -> public/ProtoKey.h
jswrapper.h -> js/Wrapper.h

--HG--
rename : js/src/jsalloc.h => js/public/AllocPolicy.h
rename : js/src/jsprf.h => js/public/Printf.h
rename : js/src/jsprototypes.h => js/public/ProtoKey.h
rename : js/src/jswrapper.h => js/public/Wrapper.h
rename : js/src/jsalloc.cpp => js/src/util/AllocPolicy.cpp
rename : js/src/jsprf.cpp => js/src/util/Printf.cpp
extra : rebase_source : 98b16d94c469202eab0303a8da844f1d0b6aa809
extra : amend_source : e0b16c1077226d6fe240f4d7096537f93b43f2b8
extra : histedit_source : d94e0ba7904a7d66742c7fac43f638aaec4fa4e5
2018-02-21 10:30:19 -06:00
Boris Zbarsky 3bf93ec28e Bug 1435483 part 18. Remove nsIException::GetResult. r=qdot
MozReview-Commit-ID: JArus2ddEsL
2018-02-05 16:34:06 -05:00
Boris Zbarsky 12e9f78050 Bug 1435483 part 16. Switch to using dom::Exception, not nsIException, in C++ code. r=qdot
nsIException is builtinclass in idl, so whatever code we had to handle
non-dom::Exception nsIExceptions is dead code.

MozReview-Commit-ID: 6VnqDWt0041
2018-02-05 16:34:05 -05:00
Boris Zbarsky fc5ae1f4a1 Bug 1435483 part 12. Add an infallible "toString" method on nsIStackFrame. r=qdot
MozReview-Commit-ID: CTCawPvw6VZ
2018-02-05 16:34:05 -05:00
Boris Zbarsky 539cfc28e6 Bug 1435483 part 11. Add an infallible "formattedStack" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: KLSzUuWt45x
2018-02-05 16:34:05 -05:00
Boris Zbarsky c8bd8682bf Bug 1435483 part 10. Add infallible "asyncCaller" and "caller" getters on nsIStackFrame. r=qdot
MozReview-Commit-ID: 8pdMDFHWlVt
2018-02-05 16:34:05 -05:00
Boris Zbarsky b7eaf4b6ae Bug 1435483 part 9. Add an infallible "name" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: ADxO2A8nkel
2018-02-05 16:34:05 -05:00
Boris Zbarsky 984978f22d Bug 1435483 part 8. Add an infallible "asyncCause" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: KpRyt21PF7W
2018-02-05 16:34:04 -05:00
Boris Zbarsky fc7c1f0034 Bug 1435483 part 7. Add an infallible "columnNumber" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: 7VJvDR0qD3G
2018-02-05 16:34:04 -05:00
Boris Zbarsky 2c00c8c971 Bug 1435483 part 6. Add an infallible "lineNumber" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: 7aYg9kJhiab
2018-02-05 16:34:04 -05:00
Boris Zbarsky 02f7baafc0 Bug 1435483 part 5. Add an infallible "filename" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: D3uuehuDqOB
2018-02-05 16:34:04 -05:00
Jon Coppeard a06421a289 Bug 1417123 - Remove or replace inclusion of js/GCAPI.h r=mccr8 2017-11-16 12:21:08 +00:00
Masatoshi Kimura 49e04cc095 Bug 1149830 - Remove nsIStackFrame::language. r=bz,mccr8
MozReview-Commit-ID: LxTiLFzNJ9Y

--HG--
extra : rebase_source : 98ca14aa59a62309dcbe0c9ed3e961c730ff9db9
2017-08-03 15:50:07 +09:00
Andrea Marchesini 7add4454d4 Bug 1331977 - CreateException doesn't use JSContext argument, r=qdot 2017-01-19 09:03:03 +01:00
Olli Pettay 0364dbc792 Bug 1326507, remove NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS, r=mccr8
--HG--
extra : rebase_source : 3ae1207308de120b7299b13ecaa95dd1612b3459
2017-01-03 21:47:55 +02:00
Michelangelo De Simone 6314d37360 Bug 1310020 - Remove DOM/bluetooth and related code. r=jst
MozReview-Commit-ID: IEhwzzBgb3x

--HG--
extra : rebase_source : 664e30c1d3babc71b2ef77c00e393fa767f4c159
2016-10-28 14:25:23 -07:00
Jon Coppeard 556585c65f Bug 1297558 - Remove explicit calls to Expose*ToActiveJS r=mccr8 2016-10-18 17:58:19 +01:00
Jon Coppeard 591ec11f61 Bug 1305236 - Don't call ExposeObjectToActiveJS on null pointer r=smaug 2016-09-29 10:18:50 +01:00
Jan de Mooij a53986bf29 Bug 1302448 part 1 - Rename CycleCollectedJSRuntime to CycleCollectedJSContext. r=mccr8
--HG--
rename : xpcom/base/CycleCollectedJSRuntime.cpp => xpcom/base/CycleCollectedJSContext.cpp
rename : xpcom/base/CycleCollectedJSRuntime.h => xpcom/base/CycleCollectedJSContext.h
extra : rebase_source : 075214b5057f151520926715b6154e99ae80a0b3
2016-09-14 15:47:32 +02:00
Kaku Kuo 03100d8735 Bug 1297648 - Create DOMException for NS_ERROR_MODULE_DOM_MEDIA error codes; r=bz
MozReview-Commit-ID: A8TgQHToCmQ

--HG--
extra : rebase_source : 36cbe0ffe5f3aa0167bf5f9512bc631c33593cb7
2016-08-24 17:30:58 +08:00
Boris Zbarsky 4821850eb8 Bug 1295322 part 2. Stop propagating through xpconnect exceptions to consumers that won't be able to work with them. r=bholley 2016-08-26 15:38:16 -04:00
Boris Zbarsky 6a73ce5a82 Bug 1295322 part 1. Make ThrowExceptionObject return void, instead of bool. r=bholley 2016-08-26 15:38:16 -04:00
Terrence Cole e57d650fcf Bug 1291928 - Expose JSSavedStack's stack before returning; r=bz 2016-08-03 16:12:51 -07:00
Boris Zbarsky 13a6409e22 Bug 1280818 part 2. Change console to capture the first non-self-hosted subsumed frame when it just needs a caller location, instead of capturing the first frame and then possibly failing to get useful location info out of it because it's self-hosted. r=baku 2016-07-21 23:41:02 -04:00
Nick Fitzgerald ea16cfab73 Bug 1280818 part 1 - Add the ability to capture the stack until the first non-self-hosted frame with the given principals; r=bz,jimb
Before this commit, one could either capture all stack frames (by passing
maxFrameCount = 0) or a maximum of N frames (by passing maxFrameCount = N). This
commit introduces the ability to capture the first frame (by default ignoring
self hosted frames) with some target principals. This new option required
replacing the `unsigned maxFrameCount` parameter with the introduction of a new
sum type to describe the stack capturing behavior:

  StackCapture = AllFrames
               | MaxFrames(unsigned n)
               | FirstSubsumedFrame(JSPrincipals* p, bool ignoreSelfHosted)

This is obviously more wordy in C++ than we'd like, but does make the stack
capturing more explicit rather than relying on the sentinal 0 to stand in for
infinity.
2016-07-21 23:40:59 -04:00
Jan de Mooij 66faed38af Bug 1277278 part 1 - Remove ContextOptions and make autoJSAPIOwnsErrorReporting the default. r=luke
--HG--
extra : rebase_source : aa1dcba100a3bb7a5057b07284cf4a99353afe5a
2016-06-07 20:30:48 +02:00
Andrea Marchesini e004a6613e Bug 1276887 - webidl "Deprecated" keyword should work in workers, r=smaug 2016-06-01 12:15:34 +02:00
Wes Kocher 043b2fdedd Backed out changeset e5f0088f8ca2 (bug 1276887) for WorkerPrivate assertions CLOSED TREE 2016-05-31 11:31:29 -07:00
Andrea Marchesini e7015103b0 Bug 1276887 - webidl "Deprecated" keyword should work in workers, r=smaug 2016-05-31 17:46:52 +02:00
Boris Zbarsky d17aec7b6a Bug 1260511 part 3. In dom::Throw, ignore the pending xpconnect exception if we were given a non-default message string (because we don't want to lose that string). Also, make sure to always clear the pending xpconnect exception there. r=khuey 2016-04-22 16:03:05 -04:00