Bug 1513039 - part5 : log warning when autoplay is blocked. r=cpearce,karlt
Wrap 'nsContentUtils::ReportToConsole()' to reduce necessary input parameters and call it when we need to log error or warning message. Show the warning when autoplay is blocked.
For web audio, this restores the console messages removed in part4 and also reports the same message when the AudioContext is blocked in the constructor.
Differential Revision: https://phabricator.services.mozilla.com/D14330

# 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/.from__future__importprint_function,unicode_literalsimportcodecsimportitertoolsimportosimportsysimporttextwrapbase_dir=os.path.abspath(os.path.dirname(__file__))sys.path.insert(0,os.path.join(base_dir,'python','mozbuild'))frommozbuild.configureimportConfigureSandboxfrommozbuild.pythonutilimportiter_modules_in_pathfrommozbuild.backend.configenvironmentimportPartialConfigEnvironmentfrommozbuild.utilimport(indented_repr,encode,)importmozpack.pathasmozpathdefmain(argv):config={}sandbox=ConfigureSandbox(config,os.environ,argv)sandbox.run(os.path.join(os.path.dirname(__file__),'moz.configure'))ifsandbox._help:return0returnconfig_status(config)defconfig_status(config):# Sanitize config data to feed config.status# Ideally, all the backend and frontend code would handle the booleans, but# there are so many things involved, that it's easier to keep config.status# untouched for now.defsanitized_bools(v):ifvisTrue:return'1'ifvisFalse:return''returnvsanitized_config={}sanitized_config['substs']={k:sanitized_bools(v)fork,vinconfig.iteritems()ifknotin('DEFINES','non_global_defines','TOPSRCDIR','TOPOBJDIR','CONFIG_STATUS_DEPS')}sanitized_config['defines']={k:sanitized_bools(v)fork,vinconfig['DEFINES'].iteritems()}sanitized_config['non_global_defines']=config['non_global_defines']sanitized_config['topsrcdir']=config['TOPSRCDIR']sanitized_config['topobjdir']=config['TOPOBJDIR']sanitized_config['mozconfig']=config.get('MOZCONFIG')# Create config.status. Eventually, we'll want to just do the work it does# here, when we're able to skip configure tests/use cached results/not rely# on autoconf.print("Creating config.status",file=sys.stderr)encoding='mbcs'ifsys.platform=='win32'else'utf-8'withcodecs.open('config.status','w',encoding)asfh:fh.write(textwrap.dedent('''\ #!%(python)s # coding=%(encoding)s from __future__ import unicode_literals from mozbuild.util import encode encoding = '%(encoding)s' ''')%{'python':config['PYTHON'],'encoding':encoding})# A lot of the build backend code is currently expecting byte# strings and breaks in subtle ways with unicode strings. (bug 1296508)fork,vinsanitized_config.iteritems():fh.write('%s = encode(%s, encoding)\n'%(k,indented_repr(v)))fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', ""'non_global_defines', 'substs', 'mozconfig']")ifconfig.get('MOZ_BUILD_APP')!='js'orconfig.get('JS_STANDALONE'):fh.write(textwrap.dedent(''' if __name__ == '__main__': from mozbuild.util import patch_main patch_main() from mozbuild.config_status import config_status args = dict([(name, globals()[name]) for name in __all__]) config_status(**args) '''))partial_config=PartialConfigEnvironment(config['TOPOBJDIR'])partial_config.write_vars(sanitized_config)# Write out a file so the build backend knows to re-run configure when# relevant Python changes.withopen('config_status_deps.in','w')asfh:forfinitertools.chain(config['CONFIG_STATUS_DEPS'],iter_modules_in_path(config['TOPOBJDIR'],config['TOPSRCDIR'])):fh.write('%s\n'%mozpath.normpath(f))# Other things than us are going to run this file, so we need to give it# executable permissions.os.chmod('config.status',0o755)ifconfig.get('MOZ_BUILD_APP')!='js'orconfig.get('JS_STANDALONE'):frommozbuild.config_statusimportconfig_status# Some values in sanitized_config also have more complex types, such as# EnumString, which using when calling config_status would currently# break the build, as well as making it inconsistent with re-running# config.status. Fortunately, EnumString derives from unicode, so it's# covered by converting unicode strings.# A lot of the build backend code is currently expecting byte strings# and breaks in subtle ways with unicode strings.returnconfig_status(args=[],**encode(sanitized_config,encoding))return0if__name__=='__main__':sys.exit(main(sys.argv))