gecko-dev/dom/interfaces/base
Kyle Huey 76e3009ab8 Bug 1179909: Refactor stable state handling. r=smaug
This is motivated by three separate but related problems:

1. Our concept of recursion depth is broken for things that run from AfterProcessNextEvent observers (e.g. Promises). We decrement the recursionDepth counter before firing observers, so a Promise callback running at the lowest event loop depth has a recursion depth of 0 (whereas a regular nsIRunnable would be 1). This is a problem because it's impossible to distinguish a Promise running after a sync XHR's onreadystatechange handler from a top-level event (since the former runs with depth 2 - 1 = 1, and the latter runs with just 1).

2. The nsIThreadObserver mechanism that is used by a lot of code to run "after" the current event is a poor fit for anything that runs script. First, the order the observers fire in is the order they were added, not anything fixed by spec. Additionally, running script can cause the event loop to spin, which is a big source of pain here (bholley has some nasty bug caused by this).

3. We run Promises from different points in the code for workers and main thread. The latter runs from XPConnect's nsIThreadObserver callbacks, while the former runs from a hardcoded call to run Promises in the worker event loop. What workers do is particularly problematic because it means we can't get the right recursion depth no matter what we do to nsThread.

The solve this, this patch does the following:

1. Consolidate some handling of microtasks and all handling of stable state from appshell and WorkerPrivate into CycleCollectedJSRuntime.
2. Make the recursionDepth counter only available to CycleCollectedJSRuntime (and its consumers) and remove it from the nsIThreadInternal and nsIThreadObserver APIs.
3. Adjust the recursionDepth counter so that microtasks run with the recursionDepth of the task they are associated with.
4. Introduce the concept of metastable state to replace appshell's RunBeforeNextEvent. Metastable state is reached after every microtask or task is completed. This provides the semantics that bent and I want for IndexedDB, where transactions autocommit at the end of a microtask and do not "spill" from one microtask into a subsequent microtask. This differs from appshell's RunBeforeNextEvent in two ways:
a) It fires between microtasks, which was the motivation for starting this.
b) It no longer ensures that we're at the same event loop depth in the native event queue. bent decided we don't care about this.
5. Reorder stable state to happen after microtasks such as Promises, per HTML. Right now we call the regular thread observers, including appshell, before the main thread observer (XPConnect), so stable state tasks happen before microtasks.
2015-08-11 06:10:46 -07:00
..
domstubs.idl Bug 1158366: Remove nsIDOMHTML[BR|Div|Heading|TableCaption|Table|Title]Element.idl. r=ehsan 2015-04-25 07:23:54 -07:00
moz.build Bug 909154. Remove the prefixed mozRequestAnimationFrame and its accoutrements. r=bkelly 2015-07-20 10:14:24 -04:00
nsIBrowserDOMWindow.idl Bug 1058116 - Pass referrer and isPrivate to openURIInFrame instead of nullptr as aOpener. r=mconley, r=smaug, r=Margaret, r=ally 2014-11-06 09:41:00 -05:00
nsIContentPermissionPrompt.idl Bug 1020179 - Let PContent manage PContentPermissionRequest. r=fabrice, r=khuey 2015-04-13 21:08:00 -04:00
nsIContentPrefService.idl
nsIContentPrefService2.idl Bug 1058435 - Add removeAllDomainsSince to ContentPrefService2. r=adw 2014-09-19 14:24:00 -04:00
nsIContentURIGrouper.idl
nsIDOMChromeWindow.idl
nsIDOMClientRect.idl
nsIDOMClientRectList.idl
nsIDOMConstructor.idl
nsIDOMCrypto.idl Bug 1116269 - Crypto/SubtleCrypto only depend on nsIGlobalObject, r=rbarnes 2015-01-09 10:55:44 -08:00
nsIDOMGlobalPropertyInitializer.idl
nsIDOMHistory.idl
nsIDOMLocation.idl
nsIDOMModalContentWindow.idl
nsIDOMNavigator.idl
nsIDOMScreen.idl
nsIDOMWindow.idl Bug 909154. Remove the prefixed mozRequestAnimationFrame and its accoutrements. r=bkelly 2015-07-20 10:14:24 -04:00
nsIDOMWindowCollection.idl
nsIDOMWindowUtils.idl Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
nsIFocusManager.idl Bug 1132518, make document navigation with F6/Shift+F6 work in e10s. This combines the document and tab navigation mechanisms together, r=smaug 2015-07-13 06:07:49 -04:00
nsIIdleObserver.idl
nsIQueryContentEventResult.idl Bug 492394 part.1 NS_QUERY_CHARACTER_AT_POINT should also return tentative caret offset for the point r=smaug, sr=smaug 2015-04-14 14:27:37 +09:00
nsIRemoteBrowser.idl Bug 1060529, send the enabled state of child process commands to the parent on update, without the test, r=smaug,ehsan 2014-12-09 10:48:27 -05:00
nsIServiceWorkerManager.idl Bug 1181887 Fall back to network if ServiceWorker script fails to load. r=ehsan r=khuey 2015-07-15 12:21:40 -07:00
nsIStructuredCloneContainer.idl Bug 1183954 - Fix Notification.data structured cloning on workers. r=robertbindar,mccr8 2015-07-30 12:44:14 -07:00
nsITabChild.idl Bug 1105666 - [BrowserAPI] Add an API to indicate this iframe could receive NFC event. r=smaug, kanru, yoshi 2015-01-22 17:40:17 +08:00
nsITabParent.idl Bug 1176239, do tab navigation in the child when moving between the parent and child process, r=smaug 2015-07-23 10:04:15 -04:00
nsITextInputProcessor.idl Bug 1119609 part.18 Add nsITextInputProcessor.commitCompositionWith() and drop aCommitString from nsITextInputProcessor.commitComposition() r=smaug, sr=smaug 2015-02-19 15:50:21 +09:00
nsITextInputProcessorCallback.idl Bug 1131026 Rename nsITextInputProcessor.init() and .initForTests() to .beginInputTransaction() and .beginInputTransactionForTests() r=smaug, sr=smaug 2015-02-10 17:09:29 +09:00