зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1546736 Part 1 - Keep track of whether docshells and workers are being watched by the devtools, r=bzbarsky.
--HG-- extra : rebase_source : 837fc73223c0e275fce716bbe1108a14d0e9afa4
This commit is contained in:
Родитель
b1eb76223f
Коммит
0c7f13ec4c
|
@ -386,7 +386,8 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
|
|||
mBlankTiming(false),
|
||||
mTitleValidForCurrentURI(false),
|
||||
mIsFrame(false),
|
||||
mSkipBrowsingContextDetachOnDestroy(false) {
|
||||
mSkipBrowsingContextDetachOnDestroy(false),
|
||||
mWatchedByDevtools(false) {
|
||||
mHistoryID.m0 = 0;
|
||||
mHistoryID.m1 = 0;
|
||||
mHistoryID.m2 = 0;
|
||||
|
@ -13548,3 +13549,16 @@ bool nsDocShell::GetIsAttemptingToNavigate() {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetWatchedByDevtools(bool* aWatched) {
|
||||
NS_ENSURE_ARG(aWatched);
|
||||
*aWatched = mWatchedByDevtools;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetWatchedByDevtools(bool aWatched) {
|
||||
mWatchedByDevtools = aWatched;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1245,6 +1245,9 @@ class nsDocShell final : public nsDocLoader,
|
|||
// docshell is destroyed, the browsing context will not be detached. This is
|
||||
// for cases where we want to preserve the BC for future use.
|
||||
bool mSkipBrowsingContextDetachOnDestroy : 1;
|
||||
|
||||
// Set when activity in this docshell is being watched by the developer tools.
|
||||
bool mWatchedByDevtools : 1;
|
||||
};
|
||||
|
||||
#endif /* nsDocShell_h__ */
|
||||
|
|
|
@ -1167,4 +1167,9 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* sense that's relevant to document.open.
|
||||
*/
|
||||
[notxpcom, nostdcall] readonly attribute boolean isAttemptingToNavigate;
|
||||
|
||||
/**
|
||||
* Whether developer tools are watching activity in this docshell.
|
||||
*/
|
||||
[infallible] attribute boolean watchedByDevtools;
|
||||
};
|
||||
|
|
|
@ -49,10 +49,9 @@ class SerializedStackHolder {
|
|||
// monitor later on. This may be called on either the main or a worker thread.
|
||||
//
|
||||
// This always creates a stack, even if the net monitor isn't active for the
|
||||
// associated window. Ideally we would only create the stack if the net monitor
|
||||
// was active, but there doesn't seem to be an easy way to determine this.
|
||||
// The operations this is used with should be rare enough and/or have enough
|
||||
// other associated costs that the perf impact is low. See bug 1546736.
|
||||
// associated window. The net monitor will only be active if the associated
|
||||
// docshell or worker's WatchedByDevtools flag is set, so this should be checked
|
||||
// before creating the stack.
|
||||
UniquePtr<SerializedStackHolder> GetCurrentStackForNetMonitor(JSContext* aCx);
|
||||
|
||||
// If aStackHolder is non-null, this notifies the net monitor that aStackHolder
|
||||
|
|
|
@ -87,6 +87,7 @@ WorkerLoadInfoData::WorkerLoadInfoData()
|
|||
mReportCSPViolations(false),
|
||||
mXHRParamsAllowed(false),
|
||||
mPrincipalIsSystem(false),
|
||||
mWatchedByDevtools(false),
|
||||
mStorageAccess(nsContentUtils::StorageAccess::eDeny),
|
||||
mFirstPartyStorageAccessGranted(false),
|
||||
mServiceWorkersTestingInWindow(false),
|
||||
|
|
|
@ -118,6 +118,7 @@ struct WorkerLoadInfoData {
|
|||
bool mReportCSPViolations;
|
||||
bool mXHRParamsAllowed;
|
||||
bool mPrincipalIsSystem;
|
||||
bool mWatchedByDevtools;
|
||||
nsContentUtils::StorageAccess mStorageAccess;
|
||||
bool mFirstPartyStorageAccessGranted;
|
||||
bool mServiceWorkersTestingInWindow;
|
||||
|
|
|
@ -2366,6 +2366,7 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
|||
loadInfo.mServiceWorkersTestingInWindow =
|
||||
aParent->ServiceWorkersTestingInWindow();
|
||||
loadInfo.mParentController = aParent->GetController();
|
||||
loadInfo.mWatchedByDevtools = aParent->IsWatchedByDevtools();
|
||||
} else {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
|
@ -2486,6 +2487,11 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
|||
|
||||
loadInfo.mXHRParamsAllowed = perm == nsIPermissionManager::ALLOW_ACTION;
|
||||
|
||||
nsIDocShell* docShell = globalWindow->GetDocShell();
|
||||
if (docShell) {
|
||||
loadInfo.mWatchedByDevtools = docShell->GetWatchedByDevtools();
|
||||
}
|
||||
|
||||
loadInfo.mFromWindow = true;
|
||||
loadInfo.mWindowID = globalWindow->WindowID();
|
||||
loadInfo.mStorageAccess =
|
||||
|
|
|
@ -768,6 +768,10 @@ class WorkerPrivate : public RelativeTimeline {
|
|||
return mLoadInfo.mServiceWorkersTestingInWindow;
|
||||
}
|
||||
|
||||
bool IsWatchedByDevtools() const {
|
||||
return mLoadInfo.mWatchedByDevtools;
|
||||
}
|
||||
|
||||
// Determine if the worker is currently loading its top level script.
|
||||
bool IsLoadingWorkerScript() const { return mLoadingWorkerScript; }
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче