gecko-dev/dom/html/moz.build
Chris Pearce 848dee9a6f Bug 1472580 - Ensure we always get a allow/cancel response to an autoplay media permission request. r=smaug
The front end code can't always guarantee to give us an allow/cancel response
to a permission request. In particular in these cases:
* if we close a tab while showing a doorhanger, or
* if we navigate a tab while showing a doorhanger, or
* if the permission prompt requested in a background tab and never shown.

Handling all of these cases is problematic; we don't get events for all of
these where it's easy and cheap to determine that we should cancel the
permission request.

Canceling the permission request is important in the autoplay-media permission
request case as there's objects waiting on the resolution of the permission
request, and they leak in ASan builds while running chrome tests if the Gecko
size of the permission request doesn't get a notification telling it to stop
waiting.

But we can however rely on the doorhanger code to drop its reference to the
nsIContentPermissionRequest object that we pass to it when the doorhanger goes
away. So we can cancel the permission request in our
nsIContentPermissionRequest's implementation's destructor in order to easily
catch all the above cases.

In order to do that, we need to split AutoplayRequest into two; one part being
the implementation of nsIContentPermissionRequest (AutoplayPermissionRequest),
and the other part being the code to own the PromiseHolder and manage the
permission request (AutoplayPermissionManager).

AutoplayPermissionRequest keeps a weak reference to AutoplayPermissionManager,
so that it can tell the AutoplayPermissionManager to reject the request promise
when it's destroyed.

This fixes the ASan leak for which I got backed out from earlier in this bug,
and also fixes the cases above.

MozReview-Commit-ID: KoVkgIqDleW

--HG--
rename : dom/html/AutoplayRequest.cpp => dom/html/AutoplayPermissionManager.cpp
rename : dom/html/AutoplayRequest.h => dom/html/AutoplayPermissionManager.h
extra : rebase_source : dbca520a93d8c416f6d64c2da027630181bb5910
2018-07-06 21:15:20 +12:00

266 lines
6.5 KiB
Python

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
with Files("**"):
BUG_COMPONENT = ("Core", "DOM")
DIRS += ['input']
MOCHITEST_MANIFESTS += [
'test/forms/mochitest.ini',
'test/mochitest.ini',
]
MOCHITEST_CHROME_MANIFESTS += [
'test/chrome.ini',
'test/forms/chrome.ini',
]
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
XPIDL_SOURCES += [
'nsIDateTimeInputArea.idl',
'nsIFormSubmitObserver.idl',
'nsIImageDocument.idl',
'nsIMenuBuilder.idl',
]
XPIDL_MODULE = 'content_html'
EXPORTS += [
'nsGenericHTMLElement.h',
'nsGenericHTMLFrameElement.h',
'nsHTMLDNSPrefetch.h',
'nsHTMLDocument.h',
'nsIConstraintValidation.h',
'nsIForm.h',
'nsIFormControl.h',
'nsIFormProcessor.h',
'nsIHTMLCollection.h',
'nsIHTMLDocument.h',
'nsIRadioGroupContainer.h',
'nsIRadioVisitor.h',
'nsITextControlElement.h',
'nsTextEditorState.h',
]
EXPORTS.mozilla += [
'AutoplayPermissionManager.h',
'AutoplayPermissionRequest.h',
'TextInputListener.h',
]
EXPORTS.mozilla.dom += [
'HTMLAllCollection.h',
'HTMLAnchorElement.h',
'HTMLAreaElement.h',
'HTMLAudioElement.h',
'HTMLBodyElement.h',
'HTMLBRElement.h',
'HTMLButtonElement.h',
'HTMLCanvasElement.h',
'HTMLDataElement.h',
'HTMLDataListElement.h',
'HTMLDetailsElement.h',
'HTMLDialogElement.h',
'HTMLDivElement.h',
'HTMLEmbedElement.h',
'HTMLFieldSetElement.h',
'HTMLFontElement.h',
'HTMLFormControlsCollection.h',
'HTMLFormElement.h',
'HTMLFormSubmission.h',
'HTMLFrameElement.h',
'HTMLFrameSetElement.h',
'HTMLHeadingElement.h',
'HTMLHRElement.h',
'HTMLIFrameElement.h',
'HTMLImageElement.h',
'HTMLInputElement.h',
'HTMLLabelElement.h',
'HTMLLegendElement.h',
'HTMLLIElement.h',
'HTMLLinkElement.h',
'HTMLMapElement.h',
'HTMLMediaElement.h',
'HTMLMenuElement.h',
'HTMLMenuItemElement.h',
'HTMLMetaElement.h',
'HTMLMeterElement.h',
'HTMLModElement.h',
'HTMLObjectElement.h',
'HTMLOptGroupElement.h',
'HTMLOptionElement.h',
'HTMLOptionsCollection.h',
'HTMLOutputElement.h',
'HTMLParagraphElement.h',
'HTMLPictureElement.h',
'HTMLPreElement.h',
'HTMLProgressElement.h',
'HTMLScriptElement.h',
'HTMLSelectElement.h',
'HTMLSharedElement.h',
'HTMLSharedListElement.h',
'HTMLSlotElement.h',
'HTMLSourceElement.h',
'HTMLSpanElement.h',
'HTMLStyleElement.h',
'HTMLSummaryElement.h',
'HTMLTableCaptionElement.h',
'HTMLTableCellElement.h',
'HTMLTableColElement.h',
'HTMLTableElement.h',
'HTMLTableRowElement.h',
'HTMLTableSectionElement.h',
'HTMLTemplateElement.h',
'HTMLTextAreaElement.h',
'HTMLTimeElement.h',
'HTMLTitleElement.h',
'HTMLTrackElement.h',
'HTMLUnknownElement.h',
'HTMLVideoElement.h',
'ImageDocument.h',
'MediaError.h',
'nsBrowserElement.h',
'PlayPromise.h',
'RadioNodeList.h',
'TextTrackManager.h',
'TimeRanges.h',
'ValidityState.h',
]
UNIFIED_SOURCES += [
'HTMLAllCollection.cpp',
'HTMLAnchorElement.cpp',
'HTMLAreaElement.cpp',
'HTMLAudioElement.cpp',
'HTMLBodyElement.cpp',
'HTMLBRElement.cpp',
'HTMLButtonElement.cpp',
'HTMLCanvasElement.cpp',
'HTMLDataElement.cpp',
'HTMLDataListElement.cpp',
'HTMLDetailsElement.cpp',
'HTMLDialogElement.cpp',
'HTMLDivElement.cpp',
'HTMLElement.cpp',
'HTMLEmbedElement.cpp',
'HTMLFieldSetElement.cpp',
'HTMLFontElement.cpp',
'HTMLFormControlsCollection.cpp',
'HTMLFormElement.cpp',
'HTMLFormSubmission.cpp',
'HTMLFrameElement.cpp',
'HTMLFrameSetElement.cpp',
'HTMLHeadingElement.cpp',
'HTMLHRElement.cpp',
'HTMLIFrameElement.cpp',
'HTMLImageElement.cpp',
'HTMLInputElement.cpp',
'HTMLLabelElement.cpp',
'HTMLLegendElement.cpp',
'HTMLLIElement.cpp',
'HTMLLinkElement.cpp',
'HTMLMapElement.cpp',
'HTMLMediaElement.cpp',
'HTMLMenuElement.cpp',
'HTMLMenuItemElement.cpp',
'HTMLMetaElement.cpp',
'HTMLMeterElement.cpp',
'HTMLModElement.cpp',
'HTMLObjectElement.cpp',
'HTMLOptGroupElement.cpp',
'HTMLOptionElement.cpp',
'HTMLOptionsCollection.cpp',
'HTMLOutputElement.cpp',
'HTMLParagraphElement.cpp',
'HTMLPictureElement.cpp',
'HTMLPreElement.cpp',
'HTMLProgressElement.cpp',
'HTMLScriptElement.cpp',
'HTMLSelectElement.cpp',
'HTMLSharedElement.cpp',
'HTMLSharedListElement.cpp',
'HTMLSlotElement.cpp',
'HTMLSourceElement.cpp',
'HTMLSpanElement.cpp',
'HTMLStyleElement.cpp',
'HTMLSummaryElement.cpp',
'HTMLTableCaptionElement.cpp',
'HTMLTableCellElement.cpp',
'HTMLTableColElement.cpp',
'HTMLTableElement.cpp',
'HTMLTableRowElement.cpp',
'HTMLTableSectionElement.cpp',
'HTMLTemplateElement.cpp',
'HTMLTextAreaElement.cpp',
'HTMLTimeElement.cpp',
'HTMLTitleElement.cpp',
'HTMLTrackElement.cpp',
'HTMLUnknownElement.cpp',
'HTMLVideoElement.cpp',
'ImageDocument.cpp',
'MediaDocument.cpp',
'MediaError.cpp',
'nsBrowserElement.cpp',
'nsDOMStringMap.cpp',
'nsGenericHTMLElement.cpp',
'nsGenericHTMLFrameElement.cpp',
'nsHTMLContentSink.cpp',
'nsHTMLDNSPrefetch.cpp',
'nsHTMLDocument.cpp',
'nsIConstraintValidation.cpp',
'nsRadioVisitor.cpp',
'nsTextEditorState.cpp',
'PlayPromise.cpp',
'RadioNodeList.cpp',
'TextTrackManager.cpp',
'TimeRanges.cpp',
'ValidityState.cpp',
'VideoDocument.cpp',
]
SOURCES += [
'AutoplayPermissionManager.cpp',
'AutoplayPermissionRequest.cpp',
# Includes npapi.h.
'PluginDocument.cpp',
]
EXTRA_COMPONENTS += [
'htmlMenuBuilder.js',
'htmlMenuBuilder.manifest'
]
include('/ipc/chromium/chromium-config.mozbuild')
LOCAL_INCLUDES += [
'/caps',
'/docshell/base',
'/dom/base',
'/dom/canvas',
'/dom/html/input',
'/dom/media',
'/dom/security',
'/dom/xbl',
'/dom/xul',
'/image',
'/layout/forms',
'/layout/generic',
'/layout/style',
'/layout/tables',
'/layout/xul',
'/netwerk/base',
]
FINAL_LIBRARY = 'xul'
if CONFIG['MOZ_ANDROID_HLS_SUPPORT']:
DEFINES['MOZ_ANDROID_HLS_SUPPORT'] = True
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']