Merge mozilla-inbound to mozilla-central. a=merge

This commit is contained in:
Dorel Luca 2018-02-07 17:05:03 +02:00
commit a539f8f7fe
8 changed files with 112 additions and 47 deletions

View file

@ -15,6 +15,7 @@
#include "mozilla/mscom/StructStream.h" #include "mozilla/mscom/StructStream.h"
#include "mozilla/Mutex.h" #include "mozilla/Mutex.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "HandlerData.h"
struct NEWEST_IA2_INTERFACE; struct NEWEST_IA2_INTERFACE;

View file

@ -402,7 +402,6 @@
} }
.ruleview-newproperty { .ruleview-newproperty {
/* (enable checkbox width: 12px) + (expander width: 15px) */
margin-inline-start: -10px; margin-inline-start: -10px;
} }

View file

@ -2385,6 +2385,17 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
} }
} }
#if defined(XP_WIN)
// Send the info needed to join the browser process's audio session.
nsID id;
nsString sessionName;
nsString iconPath;
if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
iconPath))) {
Unused << SendSetAudioSessionData(id, sessionName, iconPath);
}
#endif
#ifdef MOZ_CONTENT_SANDBOX #ifdef MOZ_CONTENT_SANDBOX
bool shouldSandbox = true; bool shouldSandbox = true;
MaybeFileDesc brokerFd = void_t(); MaybeFileDesc brokerFd = void_t();
@ -2416,16 +2427,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
KillHard("SandboxInitFailed"); KillHard("SandboxInitFailed");
} }
#endif #endif
#if defined(XP_WIN)
// Send the info needed to join the browser process's audio session.
nsID id;
nsString sessionName;
nsString iconPath;
if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
iconPath))) {
Unused << SendSetAudioSessionData(id, sessionName, iconPath);
}
#endif
{ {
RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get(); RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();

View file

@ -8,9 +8,12 @@ Unreleased
### Added ### Added
- New `--jsdebugger` flag to open the Browser Toolbox when Firefox
launches. This is useful for debugging Marionette internals.
- Introduced the temporary, boolean capability - Introduced the temporary, boolean capability
`moz:useNonSpecCompliantPointerOrigin` to `moz:useNonSpecCompliantPointerOrigin` to disable the WebDriver
disable the WebDriver conforming behavior of calculating the Pointer Origin. conforming behavior of calculating the Pointer Origin.
### Changed ### Changed

View file

@ -570,6 +570,13 @@ A helpful trick is that it is possible to bind to 0 to get the system
to atomically assign a free port. to atomically assign a free port.
#### <code>--jsdebugger</code>
Attach [browser toolbox] debugger when Firefox starts. This is
useful for debugging [Marionette] internals.
[browser toolbox]: https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox
#### <code>-v<var>[v]</var></code> #### <code>-v<var>[v]</var></code>
Increases the logging verbosity by to debug level when passing a single Increases the logging verbosity by to debug level when passing a single

View file

@ -123,6 +123,10 @@ fn app<'a, 'b>() -> App<'a, 'b> {
.long("connect-existing") .long("connect-existing")
.requires("marionette_port") .requires("marionette_port")
.help("Connect to an existing Firefox instance")) .help("Connect to an existing Firefox instance"))
.arg(Arg::with_name("jsdebugger")
.long("jsdebugger")
.takes_value(false)
.help("Attach browser toolbox debugger for Firefox"))
.arg(Arg::with_name("verbosity") .arg(Arg::with_name("verbosity")
.short("v") .short("v")
.multiple(true) .multiple(true)
@ -190,9 +194,10 @@ fn run() -> ProgramResult {
let settings = MarionetteSettings { let settings = MarionetteSettings {
port: marionette_port, port: marionette_port,
binary: binary, binary,
log_level,
connect_existing: matches.is_present("connect_existing"), connect_existing: matches.is_present("connect_existing"),
log_level: log_level, jsdebugger: matches.is_present("jsdebugger"),
}; };
let handler = MarionetteHandler::new(settings); let handler = MarionetteHandler::new(settings);
let listening = webdriver::server::start(addr, handler, &extension_routes()[..]) let listening = webdriver::server::start(addr, handler, &extension_routes()[..])

View file

@ -382,6 +382,10 @@ pub struct MarionetteSettings {
pub binary: Option<PathBuf>, pub binary: Option<PathBuf>,
pub connect_existing: bool, pub connect_existing: bool,
/// Brings up the Browser Toolbox when starting Firefox,
/// letting you debug internals.
pub jsdebugger: bool,
/// Optionally increase Marionette's verbosity by providing a log /// Optionally increase Marionette's verbosity by providing a log
/// level. The Gecko default is LogLevel::Info for optimised /// level. The Gecko default is LogLevel::Info for optimised
/// builds and LogLevel::Debug for debug builds. /// builds and LogLevel::Debug for debug builds.
@ -462,17 +466,20 @@ impl MarionetteHandler {
let mut runner = FirefoxRunner::new(&binary, profile); let mut runner = FirefoxRunner::new(&binary, profile);
// https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
runner runner
// double-dashed flags are not accepted on Windows systems
.arg("-marionette")
// https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
.env("MOZ_CRASHREPORTER", "1") .env("MOZ_CRASHREPORTER", "1")
.env("MOZ_CRASHREPORTER_NO_REPORT", "1") .env("MOZ_CRASHREPORTER_NO_REPORT", "1")
.env("MOZ_CRASHREPORTER_SHUTDOWN", "1"); .env("MOZ_CRASHREPORTER_SHUTDOWN", "1");
// double-dashed flags are not accepted on Windows systems
runner.arg("-marionette");
if self.settings.jsdebugger {
runner.arg("-jsdebugger");
}
if let Some(args) = options.args.as_ref() { if let Some(args) = options.args.as_ref() {
runner.args(args); runner.args(args);
}; }
let browser_proc = runner.start() let browser_proc = runner.start()
.map_err(|e| { .map_err(|e| {
@ -500,6 +507,14 @@ impl MarionetteHandler {
prefs.insert_slice(&extra_prefs[..]); prefs.insert_slice(&extra_prefs[..]);
if self.settings.jsdebugger {
prefs.insert("devtools.browsertoolbox.panel", Pref::new("jsdebugger".to_owned()));
prefs.insert("devtools.debugger.remote-enabled", Pref::new(true));
prefs.insert("devtools.chrome.enabled", Pref::new(true));
prefs.insert("devtools.debugger.prompt-connection", Pref::new(false));
prefs.insert("marionette.debugging.clicktostart", Pref::new(true));
}
if let Some(ref level) = self.current_log_level { if let Some(ref level) = self.current_log_level {
prefs.insert("marionette.log.level", Pref::new(level.to_string())); prefs.insert("marionette.log.level", Pref::new(level.to_string()));
}; };

View file

@ -20,6 +20,7 @@
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/Mutex.h"
#include <objbase.h> #include <objbase.h>
@ -54,6 +55,8 @@ public:
STDMETHODIMP OnSessionDisconnected(AudioSessionDisconnectReason aReason); STDMETHODIMP OnSessionDisconnected(AudioSessionDisconnectReason aReason);
private: private:
nsresult OnSessionDisconnectedInternal(); nsresult OnSessionDisconnectedInternal();
nsresult CommitAudioSessionData();
public: public:
STDMETHODIMP OnSimpleVolumeChanged(float aVolume, STDMETHODIMP OnSimpleVolumeChanged(float aVolume,
BOOL aMute, BOOL aMute,
@ -86,6 +89,8 @@ protected:
nsString mIconPath; nsString mIconPath;
nsID mSessionGroupingParameter; nsID mSessionGroupingParameter;
SessionState mState; SessionState mState;
// Guards the IAudioSessionControl
mozilla::Mutex mMutex;
ThreadSafeAutoRefCnt mRefCnt; ThreadSafeAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD NS_DECL_OWNINGTHREAD
@ -127,7 +132,8 @@ RecvAudioSessionData(const nsID& aID,
AudioSession* AudioSession::sService = nullptr; AudioSession* AudioSession::sService = nullptr;
AudioSession::AudioSession() AudioSession::AudioSession() :
mMutex("AudioSessionControl")
{ {
mState = UNINITIALIZED; mState = UNINITIALIZED;
} }
@ -254,6 +260,7 @@ AudioSession::Start()
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
MutexAutoLock lock(mMutex);
hr = manager->GetAudioSessionControl(&GUID_NULL, hr = manager->GetAudioSessionControl(&GUID_NULL,
0, 0,
getter_AddRefs(mAudioSessionControl)); getter_AddRefs(mAudioSessionControl));
@ -262,25 +269,6 @@ AudioSession::Start()
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
hr = mAudioSessionControl->SetGroupingParam((LPGUID)&mSessionGroupingParameter,
nullptr);
if (FAILED(hr)) {
StopInternal();
return NS_ERROR_FAILURE;
}
hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), nullptr);
if (FAILED(hr)) {
StopInternal();
return NS_ERROR_FAILURE;
}
hr = mAudioSessionControl->SetIconPath(mIconPath.get(), nullptr);
if (FAILED(hr)) {
StopInternal();
return NS_ERROR_FAILURE;
}
// Increments refcount of 'this'. // Increments refcount of 'this'.
hr = mAudioSessionControl->RegisterAudioSessionNotification(this); hr = mAudioSessionControl->RegisterAudioSessionNotification(this);
if (FAILED(hr)) { if (FAILED(hr)) {
@ -288,6 +276,11 @@ AudioSession::Start()
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsCOMPtr<nsIRunnable> runnable =
NewRunnableMethod("AudioSession::CommitAudioSessionData",
this, &AudioSession::CommitAudioSessionData);
NS_DispatchToMainThread(runnable);
mState = STARTED; mState = STARTED;
return NS_OK; return NS_OK;
@ -296,6 +289,8 @@ AudioSession::Start()
void void
AudioSession::StopInternal() AudioSession::StopInternal()
{ {
mMutex.AssertCurrentThreadOwns();
if (mAudioSessionControl && if (mAudioSessionControl &&
(mState == STARTED || mState == STOPPED)) { (mState == STARTED || mState == STOPPED)) {
// Decrement refcount of 'this' // Decrement refcount of 'this'
@ -318,6 +313,7 @@ AudioSession::Stop()
RefPtr<AudioSession> kungFuDeathGrip; RefPtr<AudioSession> kungFuDeathGrip;
kungFuDeathGrip.swap(sService); kungFuDeathGrip.swap(sService);
MutexAutoLock lock(mMutex);
StopInternal(); StopInternal();
} }
@ -374,6 +370,39 @@ AudioSession::SetSessionData(const nsID& aID,
return NS_OK; return NS_OK;
} }
nsresult
AudioSession::CommitAudioSessionData()
{
MutexAutoLock lock(mMutex);
if (!mAudioSessionControl) {
// Stop() was called before we had a chance to do this.
return NS_OK;
}
HRESULT hr =
mAudioSessionControl->SetGroupingParam((LPGUID)&mSessionGroupingParameter,
nullptr);
if (FAILED(hr)) {
StopInternal();
return NS_ERROR_FAILURE;
}
hr = mAudioSessionControl->SetDisplayName(mDisplayName.get(), nullptr);
if (FAILED(hr)) {
StopInternal();
return NS_ERROR_FAILURE;
}
hr = mAudioSessionControl->SetIconPath(mIconPath.get(), nullptr);
if (FAILED(hr)) {
StopInternal();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
STDMETHODIMP STDMETHODIMP
AudioSession::OnChannelVolumeChanged(DWORD aChannelCount, AudioSession::OnChannelVolumeChanged(DWORD aChannelCount,
float aChannelVolumeArray[], float aChannelVolumeArray[],
@ -419,15 +448,20 @@ AudioSession::OnSessionDisconnected(AudioSessionDisconnectReason aReason)
nsresult nsresult
AudioSession::OnSessionDisconnectedInternal() AudioSession::OnSessionDisconnectedInternal()
{ {
if (!mAudioSessionControl) {
return NS_OK; // We need to release the mutex before we call Start().
MutexAutoLock lock(mMutex);
// When successful, UnregisterAudioSessionNotification will decrement the if (!mAudioSessionControl)
// refcount of 'this'. Start will re-increment it. In the interim, return NS_OK;
// we'll need to reference ourselves.
RefPtr<AudioSession> kungFuDeathGrip(this); // When successful, UnregisterAudioSessionNotification will decrement the
mAudioSessionControl->UnregisterAudioSessionNotification(this); // refcount of 'this'. Start will re-increment it. In the interim,
mAudioSessionControl = nullptr; // we'll need to reference ourselves.
RefPtr<AudioSession> kungFuDeathGrip(this);
mAudioSessionControl->UnregisterAudioSessionNotification(this);
mAudioSessionControl = nullptr;
}
mState = AUDIO_SESSION_DISCONNECTED; mState = AUDIO_SESSION_DISCONNECTED;
CoUninitialize(); CoUninitialize();