Commit Graph
106 Commits
Author SHA1 Message Date
Andrew McCreight 53537fa230 Bug 1510760, part 5 - Support local-to-remote window proxy transplanting. r=tcampbell,peterv
When a BrowsingContext changes from being local to remote, we have to
change all window proxies from being local to remote, using
transplanting. The actual window proxy becomes a remote window
proxy. Cross compartment wrappers (CCWs) to the window proxy also
become remote window proxies in their respective compartments, rather
than CCWs to a remote proxy in the old compartment of the window
proxy, because the window is no longer actually in that
compartment. This also avoids having to figure out what Xray behavior
for remote window proxies should be.

This patch uses the transplanting support I added to
GetRemoteOuterWindowProxy() in the previous patch to ensure that the
remote proxy map holds the correct value after transplanting finishes.

It drops the requirement that both arguments to JS_TransplantObject
have the same class, because we need to transplant a window proxy with
a remote window proxy. It also deals with this by not adding origobj
to the wrapper map unless it is a CCW, to handle transplanting to a
remote proxy.

The core design here, with the remote window proxies in every
compartment, is taken from a patch by peterv.

Differential Revision: https://phabricator.services.mozilla.com/D35730
2019-07-18 19:36:19 +00:00
Andrew McCreight d572a4de73 Bug 1510760, part 4 - Add transplant support to GetRemoteOuterWindowProxy(). r=peterv
When we call GetRemoteOuterWindowProxy in the middle of a transplant,
the remote proxy that the function returns will be almost immediately
swapped with some other object. Rather than trying to fix up the
remote proxy map when that happens, this patch adds a new argument
that is a pointer to the object, if any, that the remote proxy is
going to be swapped to. This will be used in the remote proxy map.

Having a value in the remote proxy map that is not a remote proxy
could cause issues if somebody ends up calling
GetRemoteOuterWindowProxy() a second time before the transplant has
finished. To avoid that, my patch asserts that we are returning an
object with the appropriate class.

Differential Revision: https://phabricator.services.mozilla.com/D37598
2019-07-18 19:36:17 +00:00
Noemi Erli 4321d3240d Backed out 5 changesets (bug 1510760) for bustages in nsGlobalWindowOuter.cpp
Backed out changeset 19a972ea7855 (bug 1510760)
Backed out changeset 524ac8b3040d (bug 1510760)
Backed out changeset 3bc5442338bc (bug 1510760)
Backed out changeset cb12d4068aca (bug 1510760)
Backed out changeset 75b769608cce (bug 1510760)
2019-07-18 19:18:47 +03:00
Andrew McCreight 24a58efda9 Bug 1510760, part 5 - Support local-to-remote window proxy transplanting. r=tcampbell,peterv
When a BrowsingContext changes from being local to remote, we have to
change all window proxies from being local to remote, using
transplanting. The actual window proxy becomes a remote window
proxy. Cross compartment wrappers (CCWs) to the window proxy also
become remote window proxies in their respective compartments, rather
than CCWs to a remote proxy in the old compartment of the window
proxy, because the window is no longer actually in that
compartment. This also avoids having to figure out what Xray behavior
for remote window proxies should be.

This patch uses the transplanting support I added to
GetRemoteOuterWindowProxy() in the previous patch to ensure that the
remote proxy map holds the correct value after transplanting finishes.

It drops the requirement that both arguments to JS_TransplantObject
have the same class, because we need to transplant a window proxy with
a remote window proxy. It also deals with this by not adding origobj
to the wrapper map unless it is a CCW, to handle transplanting to a
remote proxy.

The core design here, with the remote window proxies in every
compartment, is taken from a patch by peterv.

Differential Revision: https://phabricator.services.mozilla.com/D35730
2019-07-18 15:02:59 +00:00
Andrew McCreight df38d35fe0 Bug 1510760, part 4 - Add transplant support to GetRemoteOuterWindowProxy(). r=peterv
When we call GetRemoteOuterWindowProxy in the middle of a transplant,
the remote proxy that the function returns will be almost immediately
swapped with some other object. Rather than trying to fix up the
remote proxy map when that happens, this patch adds a new argument
that is a pointer to the object, if any, that the remote proxy is
going to be swapped to. This will be used in the remote proxy map.

Having a value in the remote proxy map that is not a remote proxy
could cause issues if somebody ends up calling
GetRemoteOuterWindowProxy() a second time before the transplant has
finished. To avoid that, my patch asserts that we are returning an
object with the appropriate class.

Differential Revision: https://phabricator.services.mozilla.com/D37598
2019-07-18 15:02:57 +00:00
Kashav Madan cdb97e4669 Bug 1554070 - Ensure that the selected window has a targetable BrowsingContext, r=nika
When searching for a target by name, don't select a window if its associated
BrowsingContext is closed, discarded, or cached.

Differential Revision: https://phabricator.services.mozilla.com/D37876
2019-07-17 15:35:04 +00:00
Kashav Madan 154f57eed2 Bug 1527321 - Implement BrowsingContext::IsTargetable, r=nika
Renames IsActive to IsTargetable, and updates its implementation to check that
the current browsing context is neither closed nor cached.

Differential Revision: https://phabricator.services.mozilla.com/D36670
2019-07-17 15:31:04 +00:00
Nika Layzell b763de2b6a Bug 1563604 - Part 2: Assert on the sending side that BrowsingContexts are in valid states, r=peterv
This should help us more easily identify where the crashing issues are coming
from. The issue in part 1 was found due to these assertion changes.

Differential Revision: https://phabricator.services.mozilla.com/D36996
2019-07-15 20:44:57 +00:00
Nika Layzell f6076d6d71 Bug 1563604 - Part 1: Confirm detach calls before dropping refs, r=peterv
This ensures that the object is not discarded while there are still in-flight
messages from the parent process, and vice-versa, which could cause crashes if a
CC was run before any pending messages have arrived.

Differential Revision: https://phabricator.services.mozilla.com/D36995
2019-07-15 20:44:50 +00:00
Nika Layzell e60cf46ef8 Bug 1563542 - Correctly align usage of mIsDiscarded and mClosed for BrowsingContext, r=peterv
In the bug which introduced mIsDiscarded, the code was changed to not set
mClosed during Detach, and only set mIsDiscarded. This was a mistake because a
bunch of places are only reading mClosed. Specifically when creating a
BrowsingContext for an iframe, we check GetClosed() to see whether to skip
creating it. Not doing this check can lead to assertions like the one in this
bug.

This patch changes the behaviour to continue setting `mClosed`, and also updates
the relevant `GetClosed()` checks to correctly check `IsDiscarded()`

Differential Revision: https://phabricator.services.mozilla.com/D37267
2019-07-08 17:27:27 +00:00
Kris Maglione 421d522b2c Bug 1532795: Part 4 - Add helper to get BrowsingContext from WindowProxy. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D35377
2019-06-19 13:06:32 -07:00
Kris Maglione ab886207b0 Bug 1532795: Part 1 - Support sending BrowsingContexts via structured clone. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D35698
2019-07-01 15:24:09 -07:00
Andreas Farre c824bc1db2 Bug 1561899 - Add mIsDiscarded and use that when detaching. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D36195
2019-07-02 20:48:13 +00:00
Ciure Andrei 985ba69b12 Backed out changeset a30ecde306ef (bug 1555287) for causing bug 1559537 a=backout 2019-06-25 09:36:36 +03:00
Andreas Farre d46b408846 Bug 1555287 - Make sure to detach browsing context children early. r=nika
Waiting for docshells and frameloaders to destroy will leave attached
browsing contexts attached too long. In case the children of a
browsing contexts cannot be cached we want to detach all of them as
soon as possible.

Also normalizes the use of BrowsingContext::mGroup.

Differential Revision: https://phabricator.services.mozilla.com/D33602
2019-06-13 16:11:47 +00:00
Noemi Erli d2f577db57 Backed out changeset c807d0b9d872 (bug 1555287) for valgrind bustages CLOSED TREE 2019-06-13 12:50:32 +03:00
Andreas Farre 28ad206e7f Bug 1555287 - Make sure to detach browsing context children early. r=nika
Waiting for docshells and frameloaders to destroy will leave attached
browsing contexts attached too long. In case the children of a
browsing contexts cannot be cached we want to detach all of them as
soon as possible.

Also normalizes the use of BrowsingContext::mGroup.

Differential Revision: https://phabricator.services.mozilla.com/D33602
2019-06-12 15:35:17 +00:00
Nika Layzell 15f08e0857 Bug 1555753 - Always enable Browsing Context preservation in fission windows, r=farre
Differential Revision: https://phabricator.services.mozilla.com/D33544
2019-06-10 13:06:46 +00:00
Nika Layzell d5729dfedc Bug 1555488 - Part 1: Clear WindowProxy cache when flipping processes, r=peterv,mccr8
This is sorta-part of the work for bug 1510760. Currently if you do a process
switch, the window proxy state is completely borked, and a lot of stuff doesn't
work.

This patch aims to make it so that, while not transplanted correctly, methods
generally don't return the wrong WindowProxy object anymore after a process
swap.

Differential Revision: https://phabricator.services.mozilla.com/D33082
2019-06-06 14:57:18 +00:00
Valentin Gosu ecd0b9f635 Bug 1533877 - Frame navigations should check their parent's Cross-Origin policy r=nika
Differential Revision: https://phabricator.services.mozilla.com/D32972
2019-06-04 12:24:56 +00:00
shindli 6bfdff1bbd Backed out 2 changesets (bug 1555488) for ES lint failure in /builds/worker/checkouts/gecko/dom/tests/browser/browser_windowProxy_transplant.js CLOSED TREE
Backed out changeset bcc2d99534d1 (bug 1555488)
Backed out changeset 1bef4720c4ee (bug 1555488)
2019-06-03 23:41:46 +03:00
Nika Layzell 02bc505595 Bug 1555488 - Part 1: Clear WindowProxy cache when flipping processes, r=peterv,mccr8
This is sorta-part of the work for bug 1510760. Currently if you do a process
switch, the window proxy state is completely borked, and a lot of stuff doesn't
work.

This patch aims to make it so that, while not transplanted correctly, methods
generally don't return the wrong WindowProxy object anymore after a process
swap.

Differential Revision: https://phabricator.services.mozilla.com/D33082
2019-06-03 20:03:15 +00:00
shindli 133eac42ed Backed out 5 changesets (bug 1533877) for causing wpt permafailure in /html/cross-origin/anonymous.tentative.html CLOSED TREE
Backed out changeset 1804d3178cd4 (bug 1533877)
Backed out changeset b5a3e938f421 (bug 1533877)
Backed out changeset 08efb10cceb2 (bug 1533877)
Backed out changeset c4b8d755873b (bug 1533877)
Backed out changeset e53056e11429 (bug 1533877)
2019-06-03 22:06:38 +03:00
Valentin Gosu 7ace88603e Bug 1533877 - Frame navigations should check their parent's Cross-Origin policy r=nika
Differential Revision: https://phabricator.services.mozilla.com/D32972
2019-06-03 14:57:13 +00:00
Andreas Farre 807e665d15 Bug 1553490 - Make RestoreBrowsingContextChildren take an array of BCs. r=nika
Also remove BrowsingContextId now when it's not needed.

Differential Revision: https://phabricator.services.mozilla.com/D32151
2019-05-28 07:40:00 +00:00
Sylvestre Ledru 69746836db Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D30883
2019-05-25 17:46:15 +00:00
Nika Layzell bc0ae69841 Bug 1535835 - Remove global weak ref to BrowsingContext within Unlink(), r=farre
Differential Revision: https://phabricator.services.mozilla.com/D30683
2019-05-24 20:15:53 +00:00
arthur.iakab 699b884244 Backed out changeset a296439a25ff (bug 1519636) for frequent Windows cppunit failures CLOSED TREE 2019-05-24 14:26:01 +03:00
Sylvestre Ledru 10a773a4ca Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D30883
2019-05-24 09:59:17 +00:00
Nika Layzell b4046caca9 Bug 1547218 - Part 2: Stop special casing pointer types in ParamTraits specialization, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D29779
2019-05-21 17:04:39 +00:00
Kyle Machulis 20acabe83b Bug 1540839 - Add pref for preserving browsing contexts; r=nika
Still having lots of issues with tests failing, but need to get this
landed for various reasons. Followup to pref on at Bug 1550571.

Differential Revision: https://phabricator.services.mozilla.com/D30563
2019-05-14 10:51:09 -07:00
Razvan Maries e5b095be37 Backed out 8 changesets (bug 1540839) for build bustages. CLOSED TREE
Backed out changeset f7e477858ab7 (bug 1540839)
Backed out changeset 55e841a0f005 (bug 1540839)
Backed out changeset b71b58e40426 (bug 1540839)
Backed out changeset 484a54613358 (bug 1540839)
Backed out changeset b34c4d71f202 (bug 1540839)
Backed out changeset 8ff2ff524489 (bug 1540839)
Backed out changeset 27492a30286c (bug 1540839)
Backed out changeset f1c35e8e84f6 (bug 1540839)
2019-05-14 04:23:27 +03:00
Kyle Machulis 16353cb42b Bug 1540839 - Add pref for preserving browsing contexts; r=nika
Still having lots of issues with tests failing, but need to get this
landed for various reasons. Followup to pref on at Bug 1550571.

Differential Revision: https://phabricator.services.mozilla.com/D30563
2019-05-13 17:58:46 -07:00
Andreas Farre 2017546cef Bug 1549373 - Make BrowsingContexts stay alive long enough to be detached. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D30065
2019-05-06 16:14:40 +00:00
Andreas Farre b81986ceaa Bug 1547911 - Don't assert that there are no children when restoring BC. r=nika
This is essentially equal to restoring cached children and removing
current children from a BrowsingContext, which is the correct
behaviour. It would've been better if the current children were
removed in a more transparent manner, but it is more important to
remove an assert that too eagerly triggers.

Differential Revision: https://phabricator.services.mozilla.com/D29945
2019-05-05 19:26:51 +00:00
Andreas Farre 57fcd7dea9 Bug 1547871 - BrowsingContext needs a group to evict from cache. r=neha
Differential Revision: https://phabricator.services.mozilla.com/D29669
2019-05-03 16:08:40 +00:00
Nika Layzell a89705d0d2 Bug 1539959 - Ensure origin process is subscribed when attaching remote BC, r=farre
We were incorrectly not performing an EnsureSubscribed for the origin
process which a BrowsingContext came from. Normally this would mean that
the BrowsingContext could die in the parent process before the
WindowGlobalParent listener arrived, but that didn't generally happen
due to the low likelihood of a CC occuring between the two messages.

It's likely that this crash was caused by people on lower-end hardware
triggering a print. This would be a longer-running operation in the
content process between the first and second message than usual. On
systems with memory pressure, there would be a higher chance of a CC
occuring between the messages, which would then cause this crash.

This patch correctly connects the origin ContentParent to the
BrowsingContextGroup, which will prevent the CC from destroying our
objects.

In the future, it may be desirable to ensure that this doesn't happen
more reliably by using a ContentParent-local table for looking up
BrowsingContext IDs sent over IPC. This would prevent our current
dependency on the weak pointer behaviour of the current global ID cache.

Unfortunately, this patch adds no tests, and I'm not aware of a good way
to test this edge case to confirm it has been fixed. I believe that this
patch should fix the issue I mention, however.

Differential Revision: https://phabricator.services.mozilla.com/D29563
2019-05-02 08:50:12 +00:00
Andreas Farre ec6642cb16 Bug 1547911 - Only restore non-empty browsing context children. r=peterv
Also, make sure to evict the right browsing contexts from the cache.

Differential Revision: https://phabricator.services.mozilla.com/D29349
2019-04-30 16:11:03 +00:00
Andreas Farre 341b4d4af9 Bug 1547219 - Add helper for iterating ContentParents in BCG. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D29152
2019-04-30 08:45:41 +00:00
Andreas Farre 9d8b898e50 Bug 1471869 - Re-attach cached contexts in bulk. r=nika
This makes restoring from bfcache send less messages. It also
separates detach/attach from the caching logic, making it more clear
that caching is going on.

Differential Revision: https://phabricator.services.mozilla.com/D28670
2019-04-29 11:38:45 +00:00
Andreas Farre 2078dbfb55 Bug 1533447 - Part 2: Move bc caching to BrowsingContextGroup. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D28669
2019-04-29 07:01:50 +00:00
Nika Layzell b3a31e367d Bug 1544419 - Work around devtools mutating BrowsingContext parent, r=qdot
Differential Revision: https://phabricator.services.mozilla.com/D27517
2019-04-17 00:53:24 +00:00
Nika Layzell 2f37cb97de Bug 1542790 - Part 2: Use BC::GetParent and BC::GetTop for local windows, r=peterv
This is required to support getting the `parent` and `top` properties from
within remote subframes.

Differential Revision: https://phabricator.services.mozilla.com/D26559
2019-04-17 00:53:09 +00:00
Nika Layzell f37b172d9a Bug 1542790 - Part 1: BC::GetParent on toplevel windows should be self, r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D26558
2019-04-17 00:53:05 +00:00
Nika Layzell aac7e782f2 Bug 1525427 - Part 1: Expose WindowGlobalParent & Element on BrowsingContext, r=farre
Differential Revision: https://phabricator.services.mozilla.com/D25181
2019-04-17 00:51:36 +00:00
Andreas Farre b79abf7c01 Bug 1523636 - Create BrowsingContext in nsFrameLoader. r=nika,qdot
Differential Revision: https://phabricator.services.mozilla.com/D25039
2019-04-15 15:14:54 +00:00
Nika Layzell 997fbcaf21 Bug 1544421 - Actually check for a valid bc in read, r=farre
Differential Revision: https://phabricator.services.mozilla.com/D27511
2019-04-15 14:52:11 +00:00
Nika Layzell 059c2307f6 Bug 1542785 - Expose a top method on BrowsingContext to Chrome JS, r=farre
Differential Revision: https://phabricator.services.mozilla.com/D26554
2019-04-09 06:19:24 +00:00
Csoregi Natalia 7e5b45129e Backed out changeset d76b42f0d6ca (bug 1523636) for causing bug 1543015. a=backout 2019-04-10 18:46:01 +03:00
Valentin Gosu a5601d3bf3 Bug 1530303 - Put CrossOriginOpenerPolicy in BrowsingContext r=nika
Differential Revision: https://phabricator.services.mozilla.com/D23935
2019-04-09 20:10:13 +00:00