Skip to content

Commit

Permalink
Merge fx-team to m-c. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rvandermeulen committed Mar 24, 2015
2 parents aae0890 + ba18194 commit 68565c3
Show file tree
Hide file tree
Showing 74 changed files with 2,376 additions and 1,138 deletions.
3 changes: 2 additions & 1 deletion browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ pref("services.sync.prefs.sync.extensions.update.enabled", true);
pref("services.sync.prefs.sync.intl.accept_languages", true);
pref("services.sync.prefs.sync.javascript.enabled", true);
pref("services.sync.prefs.sync.layout.spellcheckDefault", true);
pref("services.sync.prefs.sync.lightweightThemes.isThemeSelected", true);
pref("services.sync.prefs.sync.lightweightThemes.selectedThemeID", true);
pref("services.sync.prefs.sync.lightweightThemes.usedThemes", true);
pref("services.sync.prefs.sync.network.cookie.cookieBehavior", true);
pref("services.sync.prefs.sync.network.cookie.lifetimePolicy", true);
Expand Down Expand Up @@ -1884,3 +1884,4 @@ pref("browser.readinglist.enabled", true);
pref("browser.readinglist.sidebarEverOpened", false);
// Enable the readinglist engine by default.
pref("readinglist.scheduler.enabled", true);
pref("readinglist.server", "https://readinglist.services.mozilla.com/v1");
4 changes: 2 additions & 2 deletions browser/base/content/browser-devedition.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let DevEdition = {
_prefName: "browser.devedition.theme.enabled",
_themePrefName: "general.skins.selectedSkin",
_lwThemePrefName: "lightweightThemes.isThemeSelected",
_lwThemePrefName: "lightweightThemes.selectedThemeID",
_devtoolsThemePrefName: "devtools.theme",

styleSheetLocation: "chrome://browser/skin/devedition.css",
Expand Down Expand Up @@ -76,7 +76,7 @@ let DevEdition = {
_updateStyleSheetFromPrefs: function() {
let lightweightThemeSelected = false;
try {
lightweightThemeSelected = Services.prefs.getBoolPref(this._lwThemePrefName);
lightweightThemeSelected = !!Services.prefs.getCharPref(this._lwThemePrefName);
} catch(e) {}

let defaultThemeSelected = false;
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/browser-syncui.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ let gSyncUI = {
let lastSync, threshold, prolonged;
try {
lastSync = new Date(Services.prefs.getCharPref("readinglist.scheduler.lastSync"));
threshold = new Date(Date.now() - Services.prefs.getIntPref("services.sync.errorhandler.networkFailureReportTimeout"));
threshold = new Date(Date.now() - Services.prefs.getIntPref("services.sync.errorhandler.networkFailureReportTimeout") * 1000);
prolonged = lastSync <= threshold;
} catch (ex) {
// no pref, assume not prolonged.
Expand Down
16 changes: 9 additions & 7 deletions browser/base/content/test/general/browser_devedition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
*/

const PREF_DEVEDITION_THEME = "browser.devedition.theme.enabled";
const PREF_LWTHEME = "lightweightThemes.isThemeSelected";
const PREF_LWTHEME = "lightweightThemes.selectedThemeID";
const PREF_LWTHEME_USED_THEMES = "lightweightThemes.usedThemes";
const PREF_DEVTOOLS_THEME = "devtools.theme";
const {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});

registerCleanupFunction(() => {
// Set preferences back to their original values
LightweightThemeManager.currentTheme = null;
Services.prefs.clearUserPref(PREF_DEVEDITION_THEME);
Services.prefs.clearUserPref(PREF_LWTHEME);
Services.prefs.clearUserPref(PREF_DEVTOOLS_THEME);
Services.prefs.clearUserPref(PREF_LWTHEME_USED_THEMES);
});

add_task(function* startTests() {
Expand All @@ -28,12 +32,12 @@ add_task(function* startTests() {
ok (DevEdition.styleSheet, "There is a devedition stylesheet when no themes are applied and pref is set.");

info ("Adding a lightweight theme.");
Services.prefs.setBoolPref(PREF_LWTHEME, true);
LightweightThemeManager.currentTheme = dummyLightweightTheme("preview0");
ok (!DevEdition.styleSheet, "The devedition stylesheet has been removed when a lightweight theme is applied.");

info ("Removing a lightweight theme.");
let onAttributeAdded = waitForBrightTitlebarAttribute();
Services.prefs.setBoolPref(PREF_LWTHEME, false);
LightweightThemeManager.currentTheme = null;
ok (DevEdition.styleSheet, "The devedition stylesheet has been added when a lightweight theme is removed.");
yield onAttributeAdded;

Expand Down Expand Up @@ -85,16 +89,14 @@ function dummyLightweightTheme(id) {
return {
id: id,
name: id,
headerURL: "http://lwttest.invalid/a.png",
footerURL: "http://lwttest.invalid/b.png",
headerURL: "resource:///chrome/browser/content/browser/defaultthemes/1.header.jpg",
iconURL: "resource:///chrome/browser/content/browser/defaultthemes/1.icon.jpg",
textcolor: "red",
accentcolor: "blue"
};
}

add_task(function* testLightweightThemePreview() {
let {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});

info ("Turning the pref on, then previewing lightweight themes");
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ add_task(function () {

let defaultTheme = header.nextSibling;
defaultTheme.doCommand();
is(Services.prefs.getBoolPref("lightweightThemes.isThemeSelected"), false, "No lwtheme should be selected");
is(Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID"), false, "No lwtheme should be selected");
});

add_task(function asyncCleanup() {
Expand Down
7 changes: 7 additions & 0 deletions browser/components/loop/MozLoopAPI.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,13 @@ function injectLoopAPI(targetWindow) {
}
},

SHARING_STATE_CHANGE: {
enumerable: true,
get: function() {
return Cu.cloneInto(SHARING_STATE_CHANGE, targetWindow);
}
},

fxAEnabled: {
enumerable: true,
get: function() {
Expand Down
16 changes: 15 additions & 1 deletion browser/components/loop/MozLoopService.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ const TWO_WAY_MEDIA_CONN_LENGTH = {
MORE_THAN_5M: "MORE_THAN_5M",
};

/**
* Buckets that we segment sharing state change telemetry probes into.
*
* @type {{WINDOW_ENABLED: String, WINDOW_DISABLED: String,
* BROWSER_ENABLED: String, BROWSER_DISABLED: String}}
*/
const SHARING_STATE_CHANGE = {
WINDOW_ENABLED: "WINDOW_ENABLED",
WINDOW_DISABLED: "WINDOW_DISABLED",
BROWSER_ENABLED: "BROWSER_ENABLED",
BROWSER_DISABLED: "BROWSER_DISABLED"
};

// See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
const PREF_LOG_LEVEL = "loop.debug.loglevel";

Expand All @@ -42,7 +55,8 @@ Cu.import("resource://gre/modules/FxAccountsOAuthClient.jsm");

Cu.importGlobalProperties(["URL"]);

this.EXPORTED_SYMBOLS = ["MozLoopService", "LOOP_SESSION_TYPE", "TWO_WAY_MEDIA_CONN_LENGTH"];
this.EXPORTED_SYMBOLS = ["MozLoopService", "LOOP_SESSION_TYPE",
"TWO_WAY_MEDIA_CONN_LENGTH", "SHARING_STATE_CHANGE"];

XPCOMUtils.defineLazyModuleGetter(this, "injectLoopAPI",
"resource:///modules/loop/MozLoopAPI.jsm");
Expand Down
4 changes: 3 additions & 1 deletion browser/components/loop/content/shared/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ loop.shared.actions = (function() {
* XXX: should move to some roomActions module - refs bug 1079284
*/
RoomFailure: Action.define("roomFailure", {
error: Object
error: Object,
// True when the failures occurs in the join room request to the loop-server.
failedJoinRequest: Boolean
}),

/**
Expand Down
38 changes: 28 additions & 10 deletions browser/components/loop/content/shared/js/activeRoomStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ loop.store.ActiveRoomStore = (function() {
});

this._leaveRoom(actionData.error.errno === REST_ERRNOS.ROOM_FULL ?
ROOM_STATES.FULL : ROOM_STATES.FAILED);
ROOM_STATES.FULL : ROOM_STATES.FAILED, actionData.failedJoinRequest);
},

/**
Expand Down Expand Up @@ -161,7 +161,10 @@ loop.store.ActiveRoomStore = (function() {
this._mozLoop.rooms.get(actionData.roomToken,
function(error, roomData) {
if (error) {
this.dispatchAction(new sharedActions.RoomFailure({error: error}));
this.dispatchAction(new sharedActions.RoomFailure({
error: error,
failedJoinRequest: false
}));
return;
}

Expand Down Expand Up @@ -293,7 +296,15 @@ loop.store.ActiveRoomStore = (function() {
this._mozLoop.rooms.join(this._storeState.roomToken,
function(error, responseData) {
if (error) {
this.dispatchAction(new sharedActions.RoomFailure({error: error}));
this.dispatchAction(new sharedActions.RoomFailure({
error: error,
// This is an explicit flag to avoid the leave happening if join
// fails. We can't track it on ROOM_STATES.JOINING as the user
// might choose to leave the room whilst the XHR is in progress
// which would then mean we'd run the race condition of not
// notifying the server of a leave.
failedJoinRequest: true
}));
return;
}

Expand Down Expand Up @@ -555,7 +566,10 @@ loop.store.ActiveRoomStore = (function() {
this._storeState.sessionToken,
function(error, responseData) {
if (error) {
this.dispatchAction(new sharedActions.RoomFailure({error: error}));
this.dispatchAction(new sharedActions.RoomFailure({
error: error,
failedJoinRequest: false
}));
return;
}

Expand All @@ -567,9 +581,12 @@ loop.store.ActiveRoomStore = (function() {
* Handles leaving a room. Clears any membership timeouts, then
* signals to the server the leave of the room.
*
* @param {ROOM_STATES} nextState The next state to switch to.
* @param {ROOM_STATES} nextState The next state to switch to.
* @param {Boolean} failedJoinRequest Optional. Set to true if the join
* request to loop-server failed. It
* will skip the leave message.
*/
_leaveRoom: function(nextState) {
_leaveRoom: function(nextState, failedJoinRequest) {
if (loop.standaloneMedia) {
loop.standaloneMedia.multiplexGum.reset();
}
Expand All @@ -592,10 +609,11 @@ loop.store.ActiveRoomStore = (function() {
delete this._timeout;
}

if (this._storeState.roomState === ROOM_STATES.JOINING ||
this._storeState.roomState === ROOM_STATES.JOINED ||
this._storeState.roomState === ROOM_STATES.SESSION_CONNECTED ||
this._storeState.roomState === ROOM_STATES.HAS_PARTICIPANTS) {
if (!failedJoinRequest &&
(this._storeState.roomState === ROOM_STATES.JOINING ||
this._storeState.roomState === ROOM_STATES.JOINED ||
this._storeState.roomState === ROOM_STATES.SESSION_CONNECTED ||
this._storeState.roomState === ROOM_STATES.HAS_PARTICIPANTS)) {
this._mozLoop.rooms.leave(this._storeState.roomToken,
this._storeState.sessionToken);
}
Expand Down
40 changes: 34 additions & 6 deletions browser/components/loop/content/shared/js/otSdkDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ loop.OTSdkDriver = (function() {
config);
this.screenshare.on("accessAllowed", this._onScreenShareGranted.bind(this));
this.screenshare.on("accessDenied", this._onScreenShareDenied.bind(this));

this._noteSharingState(options.videoSource, true);
},

/**
Expand Down Expand Up @@ -196,6 +198,7 @@ loop.OTSdkDriver = (function() {
this.screenshare.off("accessAllowed accessDenied");
this.screenshare.destroy();
delete this.screenshare;
this._noteSharingState(this._windowId ? "browser" : "window", false);
delete this._windowId;
return true;
},
Expand Down Expand Up @@ -648,15 +651,15 @@ loop.OTSdkDriver = (function() {
* @private
*/
_noteConnectionLength: function(callLengthSeconds) {
var buckets = this.mozLoop.TWO_WAY_MEDIA_CONN_LENGTH;

var bucket = this.mozLoop.TWO_WAY_MEDIA_CONN_LENGTH.SHORTER_THAN_10S;

var bucket = buckets.SHORTER_THAN_10S;
if (callLengthSeconds >= 10 && callLengthSeconds <= 30) {
bucket = this.mozLoop.TWO_WAY_MEDIA_CONN_LENGTH.BETWEEN_10S_AND_30S;
bucket = buckets.BETWEEN_10S_AND_30S;
} else if (callLengthSeconds > 30 && callLengthSeconds <= 300) {
bucket = this.mozLoop.TWO_WAY_MEDIA_CONN_LENGTH.BETWEEN_30S_AND_5M;
bucket = buckets.BETWEEN_30S_AND_5M;
} else if (callLengthSeconds > 300) {
bucket = this.mozLoop.TWO_WAY_MEDIA_CONN_LENGTH.MORE_THAN_5M;
bucket = buckets.MORE_THAN_5M;
}

this.mozLoop.telemetryAddKeyedValue("LOOP_TWO_WAY_MEDIA_CONN_LENGTH",
Expand Down Expand Up @@ -705,7 +708,32 @@ loop.OTSdkDriver = (function() {
* If set to true, make it easy to test/verify 2-way media connection
* telemetry code operation by viewing the logs.
*/
_debugTwoWayMediaTelemetry: false
_debugTwoWayMediaTelemetry: false,

/**
* Note the sharing state. If this.mozLoop is not defined, we're assumed to
* be running in the standalone client and return immediately.
*
* @param {String} type Type of sharing that was flipped. May be 'window'
* or 'tab'.
* @param {Boolean} enabled Flag that tells us if the feature was flipped on
* or off.
* @private
*/
_noteSharingState: function(type, enabled) {
if (!this.mozLoop) {
return;
}

var bucket = this.mozLoop.SHARING_STATE_CHANGE[type.toUpperCase() + "_" +
(enabled ? "ENABLED" : "DISABLED")];
if (!bucket) {
console.error("No sharing state bucket found for '" + type + "'");
return;
}

this.mozLoop.telemetryAddKeyedValue("LOOP_SHARING_STATE_CHANGE", bucket);
}
};

return OTSdkDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,29 @@ add_task(function* test_mozLoop_telemetryAdd_buckets() {
is(snapshot["BETWEEN_30S_AND_5M"].sum, 3, "TWO_WAY_MEDIA_CONN_LENGTH.BETWEEN_30S_AND_5M");
is(snapshot["MORE_THAN_5M"].sum, 4, "TWO_WAY_MEDIA_CONN_LENGTH.MORE_THAN_5M");
});

add_task(function* test_mozLoop_telemetryAdd_sharing_buckets() {
let histogramId = "LOOP_SHARING_STATE_CHANGE";
let histogram = Services.telemetry.getKeyedHistogramById(histogramId);
const SHARING_STATES = gMozLoopAPI.SHARING_STATE_CHANGE;

histogram.clear();
for (let value of [SHARING_STATES.WINDOW_ENABLED,
SHARING_STATES.WINDOW_DISABLED,
SHARING_STATES.WINDOW_DISABLED,
SHARING_STATES.BROWSER_ENABLED,
SHARING_STATES.BROWSER_ENABLED,
SHARING_STATES.BROWSER_ENABLED,
SHARING_STATES.BROWSER_DISABLED,
SHARING_STATES.BROWSER_DISABLED,
SHARING_STATES.BROWSER_DISABLED,
SHARING_STATES.BROWSER_DISABLED]) {
gMozLoopAPI.telemetryAddKeyedValue(histogramId, value);
}

let snapshot = histogram.snapshot();
Assert.strictEqual(snapshot["WINDOW_ENABLED"].sum, 1, "SHARING_STATE_CHANGE.WINDOW_ENABLED");
Assert.strictEqual(snapshot["WINDOW_DISABLED"].sum, 2, "SHARING_STATE_CHANGE.WINDOW_DISABLED");
Assert.strictEqual(snapshot["BROWSER_ENABLED"].sum, 3, "SHARING_STATE_CHANGE.BROWSER_ENABLED");
Assert.strictEqual(snapshot["BROWSER_DISABLED"].sum, 4, "SHARING_STATE_CHANGE.BROWSER_DISABLED");
});
Loading

0 comments on commit 68565c3

Please sign in to comment.