This commit is contained in:
Wes Kocher 2014-10-27 18:07:44 -07:00
Родитель 04e6137d9c 7c8bee6a68
Коммит 11059d1126
152 изменённых файлов: 2130 добавлений и 1687 удалений

Просмотреть файл

@ -15,9 +15,9 @@
<project name="platform_build" path="build" remote="b2g" revision="3a2947df41a480de1457a6dcdbf46ad0af70d8e0">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>

Просмотреть файл

@ -19,8 +19,8 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c058843242068d0df7c107e09da31b53d2e08fa6"/>

Просмотреть файл

@ -17,8 +17,8 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="be8b952fde51d8c83748b41ce232f02b2218451d"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>

Просмотреть файл

@ -15,9 +15,9 @@
<project name="platform_build" path="build" remote="b2g" revision="3a2947df41a480de1457a6dcdbf46ad0af70d8e0">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>

Просмотреть файл

@ -19,8 +19,8 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c058843242068d0df7c107e09da31b53d2e08fa6"/>

Просмотреть файл

@ -15,9 +15,9 @@
<project name="platform_build" path="build" remote="b2g" revision="3a2947df41a480de1457a6dcdbf46ad0af70d8e0">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>

Просмотреть файл

@ -17,8 +17,8 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="be8b952fde51d8c83748b41ce232f02b2218451d"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>

Просмотреть файл

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "9f4db6bcede8557cb8ac746fc977bc50bff2278b",
"revision": "641fa70735be0abcf817d4a86e7ae17d5596c816",
"repo_path": "/integration/gaia-central"
}

Просмотреть файл

@ -17,8 +17,8 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>

Просмотреть файл

@ -15,8 +15,8 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>

Просмотреть файл

@ -17,8 +17,8 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="be8b952fde51d8c83748b41ce232f02b2218451d"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>

Просмотреть файл

@ -17,8 +17,8 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="0888735b2c5932624808147b85a60d698d9d7352"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="314f305d3163cc094e6fe7701d95a98fc180b639"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="6a7fb482a03c5083ef79b41e7b0dfab27527cd04"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>

Просмотреть файл

@ -316,7 +316,7 @@ skip-if = e10s
run-if = datareporting
[browser_devedition.js]
[browser_devices_get_user_media.js]
skip-if = buildapp == 'mulet' || (os == "linux" && debug) || e10s # linux: bug 976544; e10s: Bug 973001 - appears user media notifications only happen in the child and don't make their way to the parent?
skip-if = buildapp == 'mulet' || os == "linux" || e10s # linux: bug 976544 & bug 1060315; e10s: Bug 973001 - appears user media notifications only happen in the child and don't make their way to the parent?
[browser_devices_get_user_media_about_urls.js]
skip-if = e10s # Bug 973001 - appears user media notifications only happen in the child and don't make their way to the parent?
[browser_discovery.js]

Просмотреть файл

@ -57,4 +57,5 @@ skip-if = e10s # Bug 1069162 - lots of orange
skip-if = e10s # Bug 915547 (social providers don't install)
[browser_social_window.js]
[browser_social_workercrash.js]
skip-if = !crashreporter
#skip-if = !crashreporter
skip-if = true # Bug 1060813 - frequent leaks on all platforms

Просмотреть файл

@ -201,9 +201,9 @@
<vbox id="PanelUI-panic-explanations">
<label id="PanelUI-panic-actionlist-main-label">&panicButton.view.mainActionDesc;</label>
<label id="PanelUI-panic-actionlist-windows" class="PanelUI-panic-actionlist">&panicButton.view.deleteTabsAndWindows;</label>
<label id="PanelUI-panic-actionlist-cookies" class="PanelUI-panic-actionlist">&panicButton.view.deleteCookies;</label>
<label id="PanelUI-panic-actionlist-history" class="PanelUI-panic-actionlist">&panicButton.view.deleteHistory;</label>
<label id="PanelUI-panic-actionlist-windows" class="PanelUI-panic-actionlist">&panicButton.view.deleteTabsAndWindows;</label>
<label id="PanelUI-panic-actionlist-newwindow" class="PanelUI-panic-actionlist">&panicButton.view.openNewWindow;</label>
<label id="PanelUI-panic-warning">&panicButton.view.undoWarning;</label>

Просмотреть файл

@ -179,8 +179,13 @@ CallProgressSocket.prototype = {
* and register with the Loop server.
*/
let LoopCallsInternal = {
callsData: {inUse: false},
_mocks: {webSocket: undefined},
callsData: {
inUse: false,
},
mocks: {
webSocket: undefined,
},
/**
* Callback from MozLoopPushHandler - A push notification has been received from
@ -308,7 +313,9 @@ let LoopCallsInternal = {
callData.progressURL,
callData.callId,
callData.websocketToken);
callProgress._websocket = this._mocks.webSocket;
if (this.mocks.webSocket) {
callProgress._websocket = this.mocks.webSocket;
}
// This instance of CallProgressSocket should stay alive until the underlying
// websocket is closed since it is passed to the websocket as the nsIWebSocketListener.
callProgress.connect(() => {callProgress.sendBusy();});

Просмотреть файл

@ -109,7 +109,6 @@ function getJSONPref(aName) {
// or the registration was successful. This is null if a registration attempt was
// unsuccessful.
let gRegisteredDeferred = null;
let gPushHandler = null;
let gHawkClient = null;
let gLocalizedStrings = null;
let gInitializeTimer = null;
@ -126,7 +125,12 @@ let gErrors = new Map();
* and register with the Loop server.
*/
let MozLoopServiceInternal = {
_mocks: {webSocket: undefined},
mocks: {
pushHandler: undefined,
webSocket: undefined,
},
get pushHandler() this.mocks.pushHandler || MozLoopPushHandler,
// The uri of the Loop server.
get loopServerUri() Services.prefs.getCharPref("loop.server"),
@ -307,21 +311,14 @@ let MozLoopServiceInternal = {
* Starts registration of Loop with the push server, and then will register
* with the Loop server. It will return early if already registered.
*
* @param {Object} mockPushHandler Optional, test-only mock push handler. Used
* to allow mocking of the MozLoopPushHandler.
* @param {Object} mockWebSocket Optional, test-only mock webSocket. To be passed
* through to MozLoopPushHandler.
* @returns {Promise} a promise that is resolved with no params on completion, or
* rejected with an error code or string.
*/
promiseRegisteredWithServers: function(mockPushHandler, mockWebSocket) {
promiseRegisteredWithServers: function() {
if (gRegisteredDeferred) {
return gRegisteredDeferred.promise;
}
this._mocks.webSocket = mockWebSocket;
this._mocks.pushHandler = mockPushHandler;
// Wrap push notification registration call-back in a Promise.
let registerForNotification = function(channelID, onNotification) {
return new Promise((resolve, reject) => {
@ -332,7 +329,7 @@ let MozLoopServiceInternal = {
resolve(pushUrl);
}
};
gPushHandler.register(channelID, onRegistered, onNotification);
MozLoopServiceInternal.pushHandler.register(channelID, onRegistered, onNotification);
});
};
@ -341,27 +338,28 @@ let MozLoopServiceInternal = {
// it back to null on error.
let result = gRegisteredDeferred.promise;
gPushHandler = mockPushHandler || MozLoopPushHandler;
let options = mockWebSocket ? {mockWebSocket: mockWebSocket} : {};
gPushHandler.initialize(options);
let options = this.mocks.webSocket ? { mockWebSocket: this.mocks.webSocket } : {};
this.pushHandler.initialize(options);
let callsRegGuest = registerForNotification(MozLoopService.channelIDs.callsGuest,
LoopCalls.onNotification);
let roomsRegGuest = registerForNotification(MozLoopService.channelIDs.roomsGuest,
roomsPushNotification);
let callsRegFxA = registerForNotification(MozLoopService.channelIDs.callsFxA,
LoopCalls.onNotification);
let roomsRegFxA = registerForNotification(MozLoopService.channelIDs.roomsFxA,
roomsPushNotification);
Promise.all([callsRegGuest, roomsRegGuest, callsRegFxA, roomsRegFxA])
.then((pushUrls) => {
return this.registerWithLoopServer(LOOP_SESSION_TYPE.GUEST,
{calls: pushUrls[0], rooms: pushUrls[1]}) })
.then(() => {
return this.registerWithLoopServer(LOOP_SESSION_TYPE.GUEST,{
calls: pushUrls[0],
rooms: pushUrls[1],
});
}).then(() => {
// storeSessionToken could have rejected and nulled the promise if the token was malformed.
if (!gRegisteredDeferred) {
return;
@ -873,13 +871,13 @@ let MozLoopServiceInternal = {
};
Object.freeze(MozLoopServiceInternal);
let gInitializeTimerFunc = (deferredInitialization, mockPushHandler, mockWebSocket) => {
let gInitializeTimerFunc = (deferredInitialization) => {
// Kick off the push notification service into registering after a timeout.
// This ensures we're not doing too much straight after the browser's finished
// starting up.
gInitializeTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
gInitializeTimer.initWithCallback(Task.async(function* initializationCallback() {
yield MozLoopService.register(mockPushHandler, mockWebSocket).then(Task.async(function*() {
yield MozLoopService.register().then(Task.async(function*() {
if (!MozLoopServiceInternal.fxAOAuthTokenData) {
log.debug("MozLoopService: Initialized without an already logged-in account");
deferredInitialization.resolve("initialized to guest status");
@ -890,8 +888,8 @@ let gInitializeTimerFunc = (deferredInitialization, mockPushHandler, mockWebSock
let registeredPromise =
MozLoopServiceInternal.registerWithLoopServer(
LOOP_SESSION_TYPE.FXA, {
calls: gPushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA],
rooms: gPushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA]
calls: MozLoopServiceInternal.pushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA],
rooms: MozLoopServiceInternal.pushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA]
});
registeredPromise.then(() => {
deferredInitialization.resolve("initialized to logged-in status");
@ -936,7 +934,7 @@ this.MozLoopService = {
*
* @return {Promise}
*/
initialize: Task.async(function*(mockPushHandler, mockWebSocket) {
initialize: Task.async(function*() {
// Do this here, rather than immediately after definition, so that we can
// stub out API functions for unit testing
Object.freeze(this);
@ -962,7 +960,7 @@ this.MozLoopService = {
}
let deferredInitialization = Promise.defer();
gInitializeTimerFunc(deferredInitialization, mockPushHandler, mockWebSocket);
gInitializeTimerFunc(deferredInitialization);
return deferredInitialization.promise.catch(error => {
if (typeof(error) == "object") {
@ -1088,12 +1086,10 @@ this.MozLoopService = {
* Starts registration of Loop with the push server, and then will register
* with the Loop server. It will return early if already registered.
*
* @param {Object} mockPushHandler Optional, test-only mock push handler. Used
* to allow mocking of the MozLoopPushHandler.
* @returns {Promise} a promise that is resolved with no params on completion, or
* rejected with an error code or string.
*/
register: function(mockPushHandler, mockWebSocket) {
register: function() {
log.debug("registering");
// Don't do anything if loop is not enabled.
if (!Services.prefs.getBoolPref("loop.enabled")) {
@ -1104,7 +1100,7 @@ this.MozLoopService = {
throw new Error("Loop is disabled by the soft-start mechanism");
}
return MozLoopServiceInternal.promiseRegisteredWithServers(mockPushHandler, mockWebSocket);
return MozLoopServiceInternal.promiseRegisteredWithServers();
},
/**
@ -1301,8 +1297,8 @@ this.MozLoopService = {
return tokenData;
}).then(tokenData => {
return gRegisteredDeferred.promise.then(Task.async(function*() {
let callsUrl = gPushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA],
roomsUrl = gPushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA];
let callsUrl = MozLoopServiceInternal.pushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA],
roomsUrl = MozLoopServiceInternal.pushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA];
if (callsUrl && roomsUrl) {
yield MozLoopServiceInternal.registerWithLoopServer(
LOOP_SESSION_TYPE.FXA, {calls: callsUrl, rooms: roomsUrl});
@ -1348,23 +1344,19 @@ this.MozLoopService = {
*/
logOutFromFxA: Task.async(function*() {
log.debug("logOutFromFxA");
let callsPushUrl, roomsPushUrl;
if (gPushHandler) {
callsPushUrl = gPushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA];
roomsPushUrl = gPushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA];
}
let pushHandler = MozLoopServiceInternal.pushHandler;
let callsPushUrl = pushHandler.registeredChannels[MozLoopService.channelIDs.callsFxA];
let roomsPushUrl = pushHandler.registeredChannels[MozLoopService.channelIDs.roomsFxA];
try {
if (callsPushUrl) {
yield MozLoopServiceInternal.unregisterFromLoopServer(
LOOP_SESSION_TYPE.FXA, callsPushUrl);
yield MozLoopServiceInternal.unregisterFromLoopServer(LOOP_SESSION_TYPE.FXA, callsPushUrl);
}
if (roomsPushUrl) {
yield MozLoopServiceInternal.unregisterFromLoopServer(
LOOP_SESSION_TYPE.FXA, roomsPushUrl);
yield MozLoopServiceInternal.unregisterFromLoopServer(LOOP_SESSION_TYPE.FXA, roomsPushUrl);
}
}
catch (error) {throw error}
finally {
} catch (error) {
throw error;
} finally {
MozLoopServiceInternal.clearSessionToken(LOOP_SESSION_TYPE.FXA);
}

Просмотреть файл

@ -539,11 +539,7 @@ loop.panel = (function(_, mozL10n) {
},
_onRoomListChanged: function() {
var storeState = this.props.store.getStoreState();
this.setState({
error: storeState.error,
rooms: storeState.rooms
});
this.setState(this.props.store.getStoreState());
},
_getListHeading: function() {

Просмотреть файл

@ -539,11 +539,7 @@ loop.panel = (function(_, mozL10n) {
},
_onRoomListChanged: function() {
var storeState = this.props.store.getStoreState();
this.setState({
error: storeState.error,
rooms: storeState.rooms
});
this.setState(this.props.store.getStoreState());
},
_getListHeading: function() {

Просмотреть файл

@ -434,21 +434,27 @@
cursor: pointer;
}
.feedback label {
.feedback-category-label {
display: block;
line-height: 1.5em;
}
.feedback form input[type="radio"] {
.feedback-category-radio {
margin-right: .5em;
}
.feedback form button[type="submit"],
.feedback form input[type="text"] {
.feedback > form > .btn-success,
.feedback-description {
width: 100%;
margin-top: 14px;
}
.feedback > form > .btn-success {
padding-top: .5em;
padding-bottom: .5em;
border-radius: 2px;
}
.feedback .info {
display: block;
font-size: 10px;

Просмотреть файл

@ -134,6 +134,22 @@ loop.shared.actions = (function() {
GetAllRooms: Action.define("getAllRooms", {
}),
/**
* An error occured while trying to fetch the room list.
* XXX: should move to some roomActions module - refs bug 1079284
*/
GetAllRoomsError: Action.define("getAllRoomsError", {
error: String
}),
/**
* Updates room list.
* XXX: should move to some roomActions module - refs bug 1079284
*/
UpdateRoomList: Action.define("updateRoomList", {
roomList: Array
}),
/**
* Primes localRoomStore with roomLocalId, which triggers the EmptyRoomView
* to do any necessary setup.

Просмотреть файл

@ -97,7 +97,58 @@ loop.shared.mixins = (function() {
}
};
/**
* Audio mixin. Allows playing a single audio file and ensuring it
* is stopped when the component is unmounted.
*/
var AudioMixin = {
audio: null,
_isLoopDesktop: function() {
return typeof rootObject.navigator.mozLoop === "object";
},
/**
* Starts playing an audio file, stopping any audio that is already in progress.
*
* @param {String} filename The filename to play (excluding the extension).
*/
play: function(filename, options) {
if (this._isLoopDesktop()) {
// XXX: We need navigator.mozLoop.playSound(name), see Bug 1089585.
return;
}
options = options || {};
options.loop = options.loop || false;
this._ensureAudioStopped();
this.audio = new Audio('shared/sounds/' + filename + ".ogg");
this.audio.loop = options.loop;
this.audio.play();
},
/**
* Ensures audio is stopped playing, and removes the object from memory.
*/
_ensureAudioStopped: function() {
if (this.audio) {
this.audio.pause();
this.audio.removeAttribute("src");
delete this.audio;
}
},
/**
* Ensures audio is stopped when the component is unmounted.
*/
componentWillUnmount: function() {
this._ensureAudioStopped();
}
};
return {
AudioMixin: AudioMixin,
setRootObject: setRootObject,
DropdownMenuMixin: DropdownMenuMixin,
DocumentVisibilityMixin: DocumentVisibilityMixin

Просмотреть файл

@ -10,49 +10,25 @@ loop.store = loop.store || {};
(function() {
"use strict";
/**
* Shared actions.
* @type {Object}
*/
var sharedActions = loop.shared.actions;
/**
* Room validation schema. See validate.js.
* @type {Object}
*/
var roomSchema = {
roomToken: String,
roomUrl: String,
roomName: String,
maxSize: Number,
currSize: Number,
ctime: Number
roomToken: String,
roomUrl: String,
roomName: String,
maxSize: Number,
participants: Array,
ctime: Number
};
/**
* Temporary sample raw room list data.
* XXX Should be removed when we plug the real mozLoop API for rooms.
* See bug 1074664.
* @type {Array}
*/
var temporaryRawRoomList = [{
roomToken: "_nxD4V4FflQ",
roomUrl: "http://sample/_nxD4V4FflQ",
roomName: "First Room Name",
maxSize: 2,
currSize: 0,
ctime: 1405517546
}, {
roomToken: "QzBbvGmIZWU",
roomUrl: "http://sample/QzBbvGmIZWU",
roomName: "Second Room Name",
maxSize: 2,
currSize: 0,
ctime: 1405517418
}, {
roomToken: "3jKS_Els9IU",
roomUrl: "http://sample/3jKS_Els9IU",
roomName: "Third Room Name",
maxSize: 3,
clientMaxSize: 2,
currSize: 1,
ctime: 1405518241
}];
/**
* Room type. Basically acts as a typed object constructor.
*
@ -95,7 +71,9 @@ loop.store = loop.store || {};
this.dispatcher.register(this, [
"getAllRooms",
"openRoom"
"getAllRoomsError",
"openRoom",
"updateRoomList"
]);
}
@ -119,21 +97,6 @@ loop.store = loop.store || {};
this.trigger("change");
},
/**
* Proxy to navigator.mozLoop.rooms.getAll.
* XXX Could probably be removed when bug 1074664 lands.
*
* @param {Function} cb Callback(error, roomList)
*/
_fetchRoomList: function(cb) {
// Faking this.mozLoop.rooms until it's available; bug 1074664.
if (!this.mozLoop.hasOwnProperty("rooms")) {
cb(null, temporaryRawRoomList);
return;
}
this.mozLoop.rooms.getAll(cb);
},
/**
* Maps and sorts the raw room list received from the mozLoop API.
*
@ -158,13 +121,37 @@ loop.store = loop.store || {};
* Gather the list of all available rooms from the MozLoop API.
*/
getAllRooms: function() {
this._fetchRoomList(function(err, rawRoomList) {
this.setStoreState({
error: err,
rooms: this._processRawRoomList(rawRoomList)
});
this.mozLoop.rooms.getAll(function(err, rawRoomList) {
var action;
if (err) {
action = new sharedActions.GetAllRoomsError({error: err});
} else {
action = new sharedActions.UpdateRoomList({roomList: rawRoomList});
}
this.dispatcher.dispatch(action);
}.bind(this));
}
},
/**
* Updates current error state in case getAllRooms failed.
*
* @param {sharedActions.UpdateRoomListError} actionData The action data.
*/
getAllRoomsError: function(actionData) {
this.setStoreState({error: actionData.error});
},
/**
* Updates current room list.
*
* @param {sharedActions.UpdateRoomList} actionData The action data.
*/
updateRoomList: function(actionData) {
this.setStoreState({
error: undefined,
rooms: this._processRawRoomList(actionData.roomList)
});
},
}, Backbone.Events);
loop.store.RoomListStore = RoomListStore;

Просмотреть файл

@ -135,7 +135,7 @@ loop.shared.views = (function(_, OT, l10n) {
* Conversation view.
*/
var ConversationView = React.createClass({displayName: 'ConversationView',
mixins: [Backbone.Events],
mixins: [Backbone.Events, sharedMixins.AudioMixin],
propTypes: {
sdk: React.PropTypes.object.isRequired,
@ -183,7 +183,7 @@ loop.shared.views = (function(_, OT, l10n) {
componentDidMount: function() {
if (this.props.initiate) {
this.listenTo(this.props.model, "session:connected",
this.startPublishing);
this._onSessionConnected);
this.listenTo(this.props.model, "session:stream-created",
this._streamCreated);
this.listenTo(this.props.model, ["session:peer-hungup",
@ -225,6 +225,11 @@ loop.shared.views = (function(_, OT, l10n) {
this.props.model.endSession();
},
_onSessionConnected: function(event) {
this.startPublishing(event);
this.play("connected");
},
/**
* Subscribes and attaches each created stream to a DOM element.
*
@ -397,8 +402,9 @@ loop.shared.views = (function(_, OT, l10n) {
var categories = this._getCategories();
return Object.keys(categories).map(function(category, key) {
return (
React.DOM.label({key: key},
React.DOM.label({key: key, className: "feedback-category-label"},
React.DOM.input({type: "radio", ref: "category", name: "category",
className: "feedback-category-radio",
value: category,
onChange: this.handleCategoryChange,
checked: this.state.category === category}),
@ -466,6 +472,7 @@ loop.shared.views = (function(_, OT, l10n) {
this._getCategoryFields(),
React.DOM.p(null,
React.DOM.input({type: "text", ref: "description", name: "description",
className: "feedback-description",
onChange: this.handleDescriptionFieldChange,
onFocus: this.handleDescriptionFieldFocus,
value: descriptionDisplayValue,

Просмотреть файл

@ -135,7 +135,7 @@ loop.shared.views = (function(_, OT, l10n) {
* Conversation view.
*/
var ConversationView = React.createClass({
mixins: [Backbone.Events],
mixins: [Backbone.Events, sharedMixins.AudioMixin],
propTypes: {
sdk: React.PropTypes.object.isRequired,
@ -183,7 +183,7 @@ loop.shared.views = (function(_, OT, l10n) {
componentDidMount: function() {
if (this.props.initiate) {
this.listenTo(this.props.model, "session:connected",
this.startPublishing);
this._onSessionConnected);
this.listenTo(this.props.model, "session:stream-created",
this._streamCreated);
this.listenTo(this.props.model, ["session:peer-hungup",
@ -225,6 +225,11 @@ loop.shared.views = (function(_, OT, l10n) {
this.props.model.endSession();
},
_onSessionConnected: function(event) {
this.startPublishing(event);
this.play("connected");
},
/**
* Subscribes and attaches each created stream to a DOM element.
*
@ -397,8 +402,9 @@ loop.shared.views = (function(_, OT, l10n) {
var categories = this._getCategories();
return Object.keys(categories).map(function(category, key) {
return (
<label key={key}>
<label key={key} className="feedback-category-label">
<input type="radio" ref="category" name="category"
className="feedback-category-radio"
value={category}
onChange={this.handleCategoryChange}
checked={this.state.category === category} />
@ -466,6 +472,7 @@ loop.shared.views = (function(_, OT, l10n) {
{this._getCategoryFields()}
<p>
<input type="text" ref="description" name="description"
className="feedback-description"
onChange={this.handleDescriptionFieldChange}
onFocus={this.handleDescriptionFieldFocus}
value={descriptionDisplayValue}

Двоичные данные
browser/components/loop/content/shared/sounds/connected.ogg Normal file

Двоичный файл не отображается.

Двоичные данные
browser/components/loop/content/shared/sounds/connecting.ogg Normal file

Двоичный файл не отображается.

Двоичные данные
browser/components/loop/content/shared/sounds/ringing.ogg Normal file

Двоичный файл не отображается.

Двоичные данные
browser/components/loop/content/shared/sounds/terminated.ogg Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -188,6 +188,7 @@ p.standalone-btn-label {
.btn-pending-cancel-group > .btn-cancel {
flex: 2 1 auto;
border-radius: 2px;
}
.btn-large {

Просмотреть файл

@ -262,9 +262,12 @@ loop.webapp = (function($, _, OT, mozL10n) {
});
var PendingConversationView = React.createClass({displayName: 'PendingConversationView',
mixins: [sharedMixins.AudioMixin],
getInitialState: function() {
return {
callState: this.props.callState || "connecting"
callState: "connecting"
};
},
@ -274,11 +277,13 @@ loop.webapp = (function($, _, OT, mozL10n) {
},
componentDidMount: function() {
this.play("connecting", {loop: true});
this.props.websocket.listenTo(this.props.websocket, "progress:alerting",
this._handleRingingProgress);
},
_handleRingingProgress: function() {
this.play("ringing", {loop: true});
this.setState({callState: "ringing"});
},
@ -518,6 +523,8 @@ loop.webapp = (function($, _, OT, mozL10n) {
* Ended conversation view.
*/
var EndedConversationView = React.createClass({displayName: 'EndedConversationView',
mixins: [sharedMixins.AudioMixin],
propTypes: {
conversation: React.PropTypes.instanceOf(sharedModels.ConversationModel)
.isRequired,
@ -526,6 +533,10 @@ loop.webapp = (function($, _, OT, mozL10n) {
onAfterFeedbackReceived: React.PropTypes.func.isRequired
},
componentDidMount: function() {
this.play("terminated");
},
render: function() {
document.title = mozL10n.get("standalone_title_with_status",
{clientShortname: mozL10n.get("clientShortname2"),

Просмотреть файл

@ -262,9 +262,12 @@ loop.webapp = (function($, _, OT, mozL10n) {
});
var PendingConversationView = React.createClass({
mixins: [sharedMixins.AudioMixin],
getInitialState: function() {
return {
callState: this.props.callState || "connecting"
callState: "connecting"
};
},
@ -274,11 +277,13 @@ loop.webapp = (function($, _, OT, mozL10n) {
},
componentDidMount: function() {
this.play("connecting", {loop: true});
this.props.websocket.listenTo(this.props.websocket, "progress:alerting",
this._handleRingingProgress);
},
_handleRingingProgress: function() {
this.play("ringing", {loop: true});
this.setState({callState: "ringing"});
},
@ -518,6 +523,8 @@ loop.webapp = (function($, _, OT, mozL10n) {
* Ended conversation view.
*/
var EndedConversationView = React.createClass({
mixins: [sharedMixins.AudioMixin],
propTypes: {
conversation: React.PropTypes.instanceOf(sharedModels.ConversationModel)
.isRequired,
@ -526,6 +533,10 @@ loop.webapp = (function($, _, OT, mozL10n) {
onAfterFeedbackReceived: React.PropTypes.func.isRequired
},
componentDidMount: function() {
this.play("terminated");
},
render: function() {
document.title = mozL10n.get("standalone_title_with_status",
{clientShortname: mozL10n.get("clientShortname2"),

Просмотреть файл

@ -49,6 +49,11 @@ describe("loop.panel", function() {
callback(null, []);
},
on: sandbox.stub()
},
rooms: {
getAll: function(callback) {
callback(null, []);
}
}
};

Просмотреть файл

@ -40,11 +40,13 @@ function* checkFxA401() {
add_task(function* setup() {
Services.prefs.setCharPref("loop.server", BASE_URL);
Services.prefs.setCharPref("services.push.serverURL", "ws://localhost/");
MozLoopServiceInternal.mocks.pushHandler = mockPushHandler;
registerCleanupFunction(function* () {
info("cleanup time");
yield promiseDeletedOAuthParams(BASE_URL);
Services.prefs.clearUserPref("loop.server");
Services.prefs.clearUserPref("services.push.serverURL");
MozLoopServiceInternal.mocks.pushHandler = undefined;
yield resetFxA();
Services.prefs.clearUserPref(MozLoopServiceInternal.getSessionTokenPrefName(LOOP_SESSION_TYPE.GUEST));
});
@ -251,7 +253,7 @@ add_task(function* basicAuthorizationAndRegistration() {
mockPushHandler.registrationPushURL = "https://localhost/pushUrl/guest";
// Notification observed due to the error being cleared upon successful registration.
let statusChangedPromise = promiseObserverNotified("loop-status-changed");
yield MozLoopService.register(mockPushHandler);
yield MozLoopService.register();
yield statusChangedPromise;
// Normally the same pushUrl would be registered but we change it in the test
@ -316,7 +318,7 @@ add_task(function* loginWithParams401() {
test_error: "params_401",
};
yield promiseOAuthParamsSetup(BASE_URL, params);
yield MozLoopService.register(mockPushHandler);
yield MozLoopService.register();
let loginPromise = MozLoopService.logInToFxA();
yield loginPromise.then(tokenData => {

Просмотреть файл

@ -50,14 +50,14 @@ describe("loop.store.RoomListStore", function () {
roomUrl: "http://sample/_nxD4V4FflQ",
roomName: "First Room Name",
maxSize: 2,
currSize: 0,
participants: [],
ctime: 1405517546
}, {
roomToken: "QzBbvGmIZWU",
roomUrl: "http://sample/QzBbvGmIZWU",
roomName: "Second Room Name",
maxSize: 2,
currSize: 0,
participants: [],
ctime: 1405517418
}, {
roomToken: "3jKS_Els9IU",
@ -65,7 +65,7 @@ describe("loop.store.RoomListStore", function () {
roomName: "Third Room Name",
maxSize: 3,
clientMaxSize: 2,
currSize: 1,
participants: [],
ctime: 1405518241
}];
@ -93,7 +93,7 @@ describe("loop.store.RoomListStore", function () {
it("should fetch the room list from the mozLoop API", function(done) {
store.once("change", function() {
expect(store.getStoreState().error).to.be.a.null;
expect(store.getStoreState().error).to.be.a.undefined;
expect(store.getStoreState().rooms).to.have.length.of(3);
done();
});
@ -104,7 +104,7 @@ describe("loop.store.RoomListStore", function () {
it("should order the room list using ctime desc", function(done) {
store.once("change", function() {
var storeState = store.getStoreState();
expect(storeState.error).to.be.a.null;
expect(storeState.error).to.be.a.undefined;
expect(storeState.rooms[0].ctime).eql(1405518241);
expect(storeState.rooms[1].ctime).eql(1405517546);
expect(storeState.rooms[2].ctime).eql(1405517418);

Просмотреть файл

@ -161,13 +161,20 @@ describe("loop.shared.views", function() {
});
describe("ConversationView", function() {
var fakeSDK, fakeSessionData, fakeSession, fakePublisher, model;
var fakeSDK, fakeSessionData, fakeSession, fakePublisher, model, fakeAudio;
function mountTestComponent(props) {
return TestUtils.renderIntoDocument(sharedViews.ConversationView(props));
}
beforeEach(function() {
fakeAudio = {
play: sinon.spy(),
pause: sinon.spy(),
removeAttribute: sinon.spy()
};
sandbox.stub(window, "Audio").returns(fakeAudio);
fakeSessionData = {
sessionId: "sessionId",
sessionToken: "sessionToken",
@ -350,46 +357,69 @@ describe("loop.shared.views", function() {
});
describe("Model events", function() {
it("should start streaming on session:connected", function() {
model.trigger("session:connected");
sinon.assert.calledOnce(fakeSDK.initPublisher);
});
describe("for standalone", function() {
it("should publish remote stream on session:stream-created",
function() {
var s1 = {connection: {connectionId: 42}};
model.trigger("session:stream-created", {stream: s1});
sinon.assert.calledOnce(fakeSession.subscribe);
sinon.assert.calledWith(fakeSession.subscribe, s1);
beforeEach(function() {
// In standalone, navigator.mozLoop does not exists
if (navigator.hasOwnProperty("mozLoop"))
sandbox.stub(navigator, "mozLoop", undefined);
});
it("should unpublish local stream on session:ended", function() {
comp.startPublishing();
it("should play a connected sound, once, on session:connected",
function() {
model.trigger("session:connected");
model.trigger("session:ended");
sinon.assert.calledOnce(fakeSession.unpublish);
sinon.assert.calledOnce(window.Audio);
sinon.assert.calledWithExactly(
window.Audio, "shared/sounds/connected.ogg");
expect(fakeAudio.loop).to.not.equal(true);
});
});
it("should unpublish local stream on session:peer-hungup", function() {
comp.startPublishing();
describe("for both (standalone and desktop)", function() {
it("should start streaming on session:connected", function() {
model.trigger("session:connected");
model.trigger("session:peer-hungup");
sinon.assert.calledOnce(fakeSDK.initPublisher);
});
sinon.assert.calledOnce(fakeSession.unpublish);
});
it("should publish remote stream on session:stream-created",
function() {
var s1 = {connection: {connectionId: 42}};
it("should unpublish local stream on session:network-disconnected",
function() {
model.trigger("session:stream-created", {stream: s1});
sinon.assert.calledOnce(fakeSession.subscribe);
sinon.assert.calledWith(fakeSession.subscribe, s1);
});
it("should unpublish local stream on session:ended", function() {
comp.startPublishing();
model.trigger("session:network-disconnected");
model.trigger("session:ended");
sinon.assert.calledOnce(fakeSession.unpublish);
});
it("should unpublish local stream on session:peer-hungup", function() {
comp.startPublishing();
model.trigger("session:peer-hungup");
sinon.assert.calledOnce(fakeSession.unpublish);
});
it("should unpublish local stream on session:network-disconnected",
function() {
comp.startPublishing();
model.trigger("session:network-disconnected");
sinon.assert.calledOnce(fakeSession.unpublish);
});
});
});
describe("Publisher events", function() {
@ -526,7 +556,7 @@ describe("loop.shared.views", function() {
fillSadFeedbackForm(comp, "confusing");
expect(comp.getDOMNode()
.querySelector("form input[type='text']").value).eql("");
.querySelector(".feedback-description").value).eql("");
});
it("should enable the form submit button once a predefined category is " +

Просмотреть файл

@ -575,7 +575,7 @@ describe("loop.webapp", function() {
});
describe("PendingConversationView", function() {
var view, websocket;
var view, websocket, fakeAudio;
beforeEach(function() {
websocket = new loop.CallConnectionWebSocket({
@ -585,6 +585,12 @@ describe("loop.webapp", function() {
});
sinon.stub(websocket, "cancel");
fakeAudio = {
play: sinon.spy(),
pause: sinon.spy(),
removeAttribute: sinon.spy()
};
sandbox.stub(window, "Audio").returns(fakeAudio);
view = React.addons.TestUtils.renderIntoDocument(
loop.webapp.PendingConversationView({
@ -593,6 +599,16 @@ describe("loop.webapp", function() {
);
});
describe("#componentDidMount", function() {
it("should play a looped connecting sound", function() {
sinon.assert.calledOnce(window.Audio);
sinon.assert.calledWithExactly(window.Audio, "shared/sounds/connecting.ogg");
expect(fakeAudio.loop).to.equal(true);
});
});
describe("#_cancelOutgoingCall", function() {
it("should inform the websocket to cancel the setup", function() {
var button = view.getDOMNode().querySelector(".btn-cancel");
@ -609,6 +625,13 @@ describe("loop.webapp", function() {
expect(view.state.callState).to.be.equal("ringing");
});
it("should play a looped ringing sound", function() {
websocket.trigger("progress:alerting");
sinon.assert.calledWithExactly(window.Audio, "shared/sounds/ringing.ogg");
expect(fakeAudio.loop).to.equal(true);
});
});
});
});
@ -843,9 +866,16 @@ describe("loop.webapp", function() {
});
describe("EndedConversationView", function() {
var view, conversation;
var view, conversation, fakeAudio;
beforeEach(function() {
fakeAudio = {
play: sinon.spy(),
pause: sinon.spy(),
removeAttribute: sinon.spy()
};
sandbox.stub(window, "Audio").returns(fakeAudio);
conversation = new sharedModels.ConversationModel({}, {
sdk: {}
});
@ -866,6 +896,17 @@ describe("loop.webapp", function() {
it("should render a FeedbackView", function() {
TestUtils.findRenderedComponentWithType(view, sharedViews.FeedbackView);
});
describe("#componentDidMount", function() {
it("should play a terminating sound, once", function() {
sinon.assert.calledOnce(window.Audio);
sinon.assert.calledWithExactly(window.Audio, "shared/sounds/terminated.ogg");
expect(fakeAudio.loop).to.not.equal(true);
});
});
});
describe("PromoteFirefoxView", function() {

Просмотреть файл

@ -40,8 +40,11 @@ function setupFakeLoopServer() {
Services.prefs.setCharPref("loop.server",
"http://localhost:" + loopServer.identity.primaryPort);
MozLoopServiceInternal.mocks.pushHandler = mockPushHandler;
do_register_cleanup(function() {
loopServer.stop(function() {});
MozLoopServiceInternal.mocks.pushHandler = undefined;
});
}

Просмотреть файл

@ -19,17 +19,12 @@ let msgHandler = function(msg) {
msg.reason === "busy") {
actionReceived = true;
}
}
let mockWebSocket = new MockWebSocketChannel({defaultMsgHandler: msgHandler});
LoopCallsInternal._mocks.webSocket = mockWebSocket;
Services.io.offline = false;
};
add_test(function test_busy_2guest_calls() {
actionReceived = false;
MozLoopService.register(mockPushHandler, mockWebSocket).then(() => {
MozLoopService.register().then(() => {
let opened = 0;
Chat.open = function() {
opened++;
@ -52,7 +47,7 @@ add_test(function test_busy_2guest_calls() {
add_test(function test_busy_1fxa_1guest_calls() {
actionReceived = false;
MozLoopService.register(mockPushHandler, mockWebSocket).then(() => {
MozLoopService.register().then(() => {
let opened = 0;
Chat.open = function() {
opened++;
@ -76,7 +71,7 @@ add_test(function test_busy_1fxa_1guest_calls() {
add_test(function test_busy_2fxa_calls() {
actionReceived = false;
MozLoopService.register(mockPushHandler, mockWebSocket).then(() => {
MozLoopService.register().then(() => {
let opened = 0;
Chat.open = function() {
opened++;
@ -99,7 +94,7 @@ add_test(function test_busy_2fxa_calls() {
add_test(function test_busy_1guest_1fxa_calls() {
actionReceived = false;
MozLoopService.register(mockPushHandler, mockWebSocket).then(() => {
MozLoopService.register().then(() => {
let opened = 0;
Chat.open = function() {
opened++;
@ -120,8 +115,7 @@ add_test(function test_busy_1guest_1fxa_calls() {
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
// Setup fake login state so we get FxA requests.
@ -129,6 +123,11 @@ function run_test()
MozLoopServiceInternal.fxAOAuthTokenData = {token_type:"bearer",access_token:"1bad3e44b12f77a88fe09f016f6a37c42e40f974bc7a8b432bb0d2f0e37e1752",scope:"profile"};
MozLoopServiceInternal.fxAOAuthProfile = {email: "test@example.com", uid: "abcd1234"};
let mockWebSocket = new MockWebSocketChannel({defaultMsgHandler: msgHandler});
LoopCallsInternal.mocks.webSocket = mockWebSocket;
Services.io.offline = false;
// For each notification received from the PushServer, MozLoopService will first query
// for any pending calls on the FxA hawk session and then again using the guest session.
// A pair of response objects in the callsResponses array will be consumed for each
@ -178,7 +177,7 @@ function run_test()
// clear test pref
Services.prefs.clearUserPref("loop.seenToS");
LoopCallsInternal._mocks.webSocket = undefined;
LoopCallsInternal.mocks.webSocket = undefined;
});
run_next_test();

Просмотреть файл

@ -31,7 +31,7 @@ add_test(function test_set_do_not_disturb() {
add_test(function test_do_not_disturb_disabled_should_open_chat_window() {
MozLoopService.doNotDisturb = false;
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
let opened = false;
Chat.open = function() {
opened = true;
@ -64,8 +64,7 @@ add_test(function test_do_not_disturb_enabled_shouldnt_open_chat_window() {
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
loopServer.registerPathHandler("/registration", (request, response) => {

Просмотреть файл

@ -10,7 +10,7 @@ let openChatOrig = Chat.open;
add_test(function test_openChatWindow_on_notification() {
Services.prefs.setCharPref("loop.seenToS", "unseen");
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
let opened = false;
Chat.open = function() {
opened = true;
@ -32,8 +32,7 @@ add_test(function test_openChatWindow_on_notification() {
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
loopServer.registerPathHandler("/registration", (request, response) => {

Просмотреть файл

@ -17,7 +17,7 @@ Cu.import("resource://services-common/utils.js");
add_test(function test_register_websocket_success_loop_server_fail() {
mockPushHandler.registrationResult = "404";
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
do_throw("should not succeed when loop server registration fails");
}, (err) => {
// 404 is an expected failure indicated by the lack of route being set
@ -49,15 +49,14 @@ add_test(function test_register_success() {
response.processAsync();
response.finish();
});
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
run_next_test();
}, err => {
do_throw("shouldn't error on a successful request");
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
do_register_cleanup(function() {

Просмотреть файл

@ -26,7 +26,7 @@ add_task(function test_initialize_with_expired_urls_and_no_auth_token() {
Services.prefs.setIntPref(LOOP_URL_EXPIRY_PREF, nowSeconds - 2);
Services.prefs.clearUserPref(LOOP_FXA_TOKEN_PREF);
yield MozLoopService.initialize(mockPushHandler).then((msg) => {
yield MozLoopService.initialize().then((msg) => {
Assert.equal(msg, "registration not needed", "Initialize should not register when the " +
"URLs are expired and there are no auth tokens");
}, (error) => {
@ -42,7 +42,7 @@ add_task(function test_initialize_with_urls_and_no_auth_token() {
response.setStatusLine(null, 200, "OK");
});
yield MozLoopService.initialize(mockPushHandler).then((msg) => {
yield MozLoopService.initialize().then((msg) => {
Assert.equal(msg, "initialized to guest status", "Initialize should register as a " +
"guest when no auth tokens but expired URLs");
}, (error) => {
@ -66,12 +66,11 @@ add_task(function test_initialize_with_invalid_fxa_token() {
}));
});
yield MozLoopService.initialize(mockPushHandler).then(() => {
yield MozLoopService.initialize().then(() => {
Assert.ok(false, "Initializing with an invalid token should reject the promise");
},
(error) => {
let pushHandler = Cu.import("resource:///modules/loop/MozLoopService.jsm", {}).gPushHandler;
Assert.equal(pushHandler.pushUrl, kEndPointUrl, "Push URL should match");
Assert.equal(MozLoopServiceInternal.pushHandler.pushUrl, kEndPointUrl, "Push URL should match");
Assert.equal(Services.prefs.getCharPref(LOOP_FXA_TOKEN_PREF), "",
"FXA pref should be cleared if token was invalid");
Assert.equal(Services.prefs.getCharPref(LOOP_FXA_PROFILE_PREF), "",
@ -86,7 +85,7 @@ add_task(function test_initialize_with_fxa_token() {
response.setStatusLine(null, 200, "OK");
});
yield MozLoopService.initialize(mockPushHandler).then(() => {
yield MozLoopService.initialize().then(() => {
Assert.equal(Services.prefs.getCharPref(LOOP_FXA_TOKEN_PREF), FAKE_FXA_TOKEN_DATA,
"FXA pref should still be set after initialization");
Assert.equal(Services.prefs.getCharPref(LOOP_FXA_PROFILE_PREF), FAKE_FXA_PROFILE,
@ -98,9 +97,11 @@ function run_test() {
setupFakeLoopServer();
// Note, this is just used to speed up the test.
Services.prefs.setIntPref(LOOP_INITIAL_DELAY_PREF, 0);
MozLoopServiceInternal.mocks.pushHandler = mockPushHandler;
mockPushHandler.pushUrl = kEndPointUrl;
do_register_cleanup(function() {
MozLoopServiceInternal.mocks.pushHandler = undefined;
Services.prefs.clearUserPref(LOOP_INITIAL_DELAY_PREF);
Services.prefs.clearUserPref(LOOP_FXA_TOKEN_PREF);
Services.prefs.clearUserPref(LOOP_FXA_PROFILE_PREF);

Просмотреть файл

@ -31,7 +31,7 @@ add_test(function test_registration_invalid_token() {
response.finish();
});
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
// Due to the way the time stamp checking code works in hawkclient, we expect a couple
// of authorization requests before we reset the token.
Assert.equal(authorizationAttempts, 2);
@ -43,8 +43,7 @@ add_test(function test_registration_invalid_token() {
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
do_register_cleanup(function() {

Просмотреть файл

@ -16,7 +16,7 @@ add_test(function test_registration_returns_hawk_session_token() {
response.finish();
});
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
var hawkSessionPref;
try {
hawkSessionPref = Services.prefs.getCharPref("loop.hawk-session-token");
@ -31,8 +31,7 @@ add_test(function test_registration_returns_hawk_session_token() {
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
do_register_cleanup(function() {

Просмотреть файл

@ -24,7 +24,7 @@ add_test(function test_registration_uses_hawk_session_token() {
response.finish();
});
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
run_next_test();
}, err => {
do_throw("shouldn't error on a succesful request");
@ -32,8 +32,7 @@ add_test(function test_registration_uses_hawk_session_token() {
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
do_register_cleanup(function() {

Просмотреть файл

@ -16,7 +16,7 @@ add_test(function test_registration_handles_bogus_hawk_token() {
response.finish();
});
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
do_throw("should not succeed with a bogus token");
}, err => {
@ -36,8 +36,7 @@ add_test(function test_registration_handles_bogus_hawk_token() {
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
do_register_cleanup(function() {
@ -45,5 +44,4 @@ function run_test()
});
run_next_test();
}

Просмотреть файл

@ -83,7 +83,7 @@ add_test(function test_getAllRooms() {
returnRoomDetails(response, "Third Room Name");
});
MozLoopService.register(mockPushHandler).then(() => {
MozLoopService.register().then(() => {
LoopRooms.getAll((error, rooms) => {
do_check_false(error);
@ -113,8 +113,7 @@ add_test(function test_getAllRooms() {
});
});
function run_test()
{
function run_test() {
setupFakeLoopServer();
mockPushHandler.registrationPushURL = kEndPointUrl;

Просмотреть файл

@ -2,6 +2,47 @@
* 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/. */
// Sample from https://wiki.mozilla.org/Loop/Architecture/Rooms#GET_.2Frooms
var fakeRooms = [
{
"roomToken": "_nxD4V4FflQ",
"roomName": "First Room Name",
"roomUrl": "http://localhost:3000/rooms/_nxD4V4FflQ",
"roomOwner": "Alexis",
"maxSize": 2,
"creationTime": 1405517546,
"ctime": 1405517546,
"expiresAt": 1405534180,
"participants": []
},
{
"roomToken": "QzBbvGmIZWU",
"roomName": "Second Room Name",
"roomUrl": "http://localhost:3000/rooms/QzBbvGmIZWU",
"roomOwner": "Alexis",
"maxSize": 2,
"creationTime": 1405517546,
"ctime": 1405517546,
"expiresAt": 1405534180,
"participants": []
},
{
"roomToken": "3jKS_Els9IU",
"roomName": "UX Discussion",
"roomUrl": "http://localhost:3000/rooms/3jKS_Els9IU",
"roomOwner": "Alexis",
"maxSize": 2,
"clientMaxSize": 2,
"creationTime": 1405517546,
"ctime": 1405517818,
"expiresAt": 1405534180,
"participants": [
{ "displayName": "Alexis", "account": "alexis@example.com", "roomConnectionId": "2a1787a6-4a73-43b5-ae3e-906ec1e763cb" },
{ "displayName": "Adam", "roomConnectionId": "781f012b-f1ea-4ce1-9105-7cfc36fb4ec7" }
]
}
];
/**
* Faking the mozLoop object which doesn't exist in regular web pages.
* @type {Object}
@ -22,5 +63,10 @@ navigator.mozLoop = {
},
on: function() {}
},
rooms: {
getAll: function(callback) {
callback(null, fakeRooms);
}
},
fxAEnabled: true
};

Просмотреть файл

@ -59,7 +59,7 @@
var dispatcher = new loop.Dispatcher();
var roomListStore = new loop.store.RoomListStore({
dispatcher: dispatcher,
mozLoop: {}
mozLoop: navigator.mozLoop
});
// Local mocks

Просмотреть файл

@ -59,7 +59,7 @@
var dispatcher = new loop.Dispatcher();
var roomListStore = new loop.store.RoomListStore({
dispatcher: dispatcher,
mozLoop: {}
mozLoop: navigator.mozLoop
});
// Local mocks

Просмотреть файл

@ -97,6 +97,19 @@ var gMainPane = {
e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
#endif
#ifdef MOZ_DEV_EDITION
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
setEventListener("getStarted", "click", gMainPane.onGetStarted);
OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
() => separateProfileModeCheckbox.checked = true);
#endif
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
@ -154,6 +167,66 @@ var gMainPane = {
},
#endif
#ifdef MOZ_DEV_EDITION
separateProfileModeChange: function ()
{
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestartNotSameProfile);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
if (error) {
Cu.reportError("Failed to toggle separate profile mode: " + error);
}
}
const Cc = Components.classes, Ci = Components.interfaces;
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
let brandName = document.getElementById("bundleBrand").getString("brandShortName");
let bundle = document.getElementById("bundlePreferences");
let msg = bundle.getFormattedString(separateProfileModeCheckbox.checked ?
"featureEnableRequiresRestart" : "featureDisableRequiresRestart",
[brandName]);
let title = bundle.getFormattedString("shouldRestartTitle", [brandName]);
let shouldProceed = Services.prompt.confirm(window, title, msg)
if (shouldProceed) {
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
"restart");
shouldProceed = !cancelQuit.data;
if (shouldProceed) {
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
if (separateProfileModeCheckbox.checked) {
OS.File.remove(ignoreSeparateProfile).then(quitApp, revertCheckbox);
} else {
OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(quitApp, revertCheckbox);
}
return;
}
}
// Revert the checkbox in case we didn't quit
revertCheckbox();
},
onGetStarted: function (aEvent) {
const Cc = Components.classes, Ci = Components.interfaces;
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
if (win) {
let accountsTab = win.gBrowser.addTab("about:accounts?action=migrateToDevEdition");
win.gBrowser.selectedTab = accountsTab;
}
},
#endif
// HOME PAGE
/*

Просмотреть файл

@ -117,6 +117,17 @@
hidden="true">
<caption><label>&startup.label;</label></caption>
#ifdef MOZ_DEV_EDITION
<vbox id="separateProfileBox">
<checkbox id="separateProfileMode"
label="&separateProfileMode.label;"/>
<hbox align="center" class="indent">
<label id="useFirefoxSync">&useFirefoxSync.label;</label>
<label id="getStarted" class="text-link">&getStarted.label;</label>
</hbox>
</vbox>
#endif
#ifdef E10S_TESTING_ONLY
<checkbox id="e10sAutoStart"
label="Enable E10S (multi-process)"/>
@ -126,13 +137,13 @@
<vbox id="defaultBrowserBox">
<hbox align="center">
<checkbox id="alwaysCheckDefault" preference="browser.shell.checkDefaultBrowser"
label="&alwaysCheckDefault.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
label="&alwaysCheckDefault2.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
</hbox>
<deck id="setDefaultPane">
<hbox align="center" class="indent">
<label id="isNotDefaultLabel" flex="1">&isNotDefault.label;</label>
<button id="setDefaultButton"
label="&setAsMyDefaultBrowser.label;" accesskey="&setAsMyDefaultBrowser.accesskey;"
label="&setAsMyDefaultBrowser2.label;" accesskey="&setAsMyDefaultBrowser2.accesskey;"
preference="pref.general.disable_button.default_browser"/>
</hbox>
<hbox align="center" class="indent">

Просмотреть файл

@ -95,6 +95,8 @@ function gotoPref(aCategory) {
categories.selectedItem = item;
window.history.replaceState(category, document.title);
search(category, "data-category");
let mainContent = document.querySelector(".main-content");
mainContent.scrollTop = 0;
}
function search(aQuery, aAttribute) {

Просмотреть файл

@ -7,8 +7,9 @@ support-files =
[browser_advanced_update.js]
[browser_bug410900.js]
[browser_bug731866.js]
[browser_bug1020245_openPreferences_to_paneContent.js]
[browser_bug795764_cachedisabled.js]
[browser_bug1018066_resetScrollPosition.js]
[browser_bug1020245_openPreferences_to_paneContent.js]
[browser_connection.js]
[browser_connection_bug388287.js]
[browser_healthreport.js]

Просмотреть файл

@ -0,0 +1,27 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Services.prefs.setBoolPref("browser.preferences.inContent", true);
let originalWindowHeight;
registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.preferences.inContent");
window.resizeTo(window.outerWidth, originalWindowHeight);
while (gBrowser.tabs[1])
gBrowser.removeTab(gBrowser.tabs[1]);
});
add_task(function() {
originalWindowHeight = window.outerHeight;
window.resizeTo(window.outerWidth, 300);
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneApplications", undefined, {leaveOpen: true});
is(prefs.selectedPane, "paneApplications", "Applications pane was selected");
let mainContent = gBrowser.contentDocument.querySelector(".main-content");
mainContent.scrollTop = 50;
is(mainContent.scrollTop, 50, "main-content should be scrolled 50 pixels");
gBrowser.contentWindow.gotoPref("paneGeneral");
is(mainContent.scrollTop, 0,
"Switching to a different category should reset the scroll position");
});

Просмотреть файл

@ -25,28 +25,6 @@ add_task(function() {
is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
});
function openPreferencesViaOpenPreferencesAPI(aPane, aAdvancedTab) {
let deferred = Promise.defer();
gBrowser.selectedTab = gBrowser.addTab("about:blank");
openPreferences(aPane, aAdvancedTab ? {advancedTab: aAdvancedTab} : undefined);
let newTabBrowser = gBrowser.selectedBrowser;
newTabBrowser.addEventListener("Initialized", function PrefInit() {
newTabBrowser.removeEventListener("Initialized", PrefInit, true);
newTabBrowser.contentWindow.addEventListener("load", function prefLoad() {
newTabBrowser.contentWindow.removeEventListener("load", prefLoad);
let win = gBrowser.contentWindow;
let selectedPane = win.history.state;
let doc = win.document;
let selectedAdvancedTab = aAdvancedTab && doc.getElementById("advancedPrefs").selectedTab.id;
gBrowser.removeCurrentTab();
deferred.resolve({selectedPane: selectedPane, selectedAdvancedTab: selectedAdvancedTab});
});
}, true);
return deferred.promise;
}
function openPreferencesViaHash(aPane) {
let deferred = Promise.defer();
gBrowser.selectedTab = gBrowser.addTab("about:preferences" + (aPane ? "#" + aPane : ""));

Просмотреть файл

@ -117,3 +117,25 @@ function waitForEvent(aSubject, aEventName, aTimeoutMs, aTarget) {
return eventDeferred.promise.then(cleanup, cleanup);
}
function openPreferencesViaOpenPreferencesAPI(aPane, aAdvancedTab, aOptions) {
let deferred = Promise.defer();
gBrowser.selectedTab = gBrowser.addTab("about:blank");
openPreferences(aPane, aAdvancedTab ? {advancedTab: aAdvancedTab} : undefined);
let newTabBrowser = gBrowser.selectedBrowser;
newTabBrowser.addEventListener("Initialized", function PrefInit() {
newTabBrowser.removeEventListener("Initialized", PrefInit, true);
newTabBrowser.contentWindow.addEventListener("load", function prefLoad() {
newTabBrowser.contentWindow.removeEventListener("load", prefLoad);
let win = gBrowser.contentWindow;
let selectedPane = win.history.state;
let doc = win.document;
let selectedAdvancedTab = aAdvancedTab && doc.getElementById("advancedPrefs").selectedTab.id;
if (!aOptions || !aOptions.leaveOpen)
gBrowser.removeCurrentTab();
deferred.resolve({selectedPane: selectedPane, selectedAdvancedTab: selectedAdvancedTab});
});
}, true);
return deferred.promise;
}

Просмотреть файл

@ -60,12 +60,87 @@ var gMainPane = {
this.updateBrowserStartupLastSession();
#ifdef MOZ_DEV_EDITION
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
let listener = gMainPane.separateProfileModeChange.bind(gMainPane);
separateProfileModeCheckbox.addEventListener("command", listener);
let getStartedLink = document.getElementById("getStarted");
let syncListener = gMainPane.onGetStarted.bind(gMainPane);
getStartedLink.addEventListener("click", syncListener);
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
() => separateProfileModeCheckbox.checked = true);
#endif
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(window, "main-pane-loaded", null);
},
#ifdef MOZ_DEV_EDITION
separateProfileModeChange: function ()
{
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestartNotSameProfile);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
if (error) {
Cu.reportError("Failed to toggle separate profile mode: " + error);
}
}
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
let brandName = document.getElementById("bundleBrand").getString("brandShortName");
let bundle = document.getElementById("bundlePreferences");
let msg = bundle.getFormattedString(separateProfileModeCheckbox.checked ?
"featureEnableRequiresRestart" : "featureDisableRequiresRestart",
[brandName]);
let title = bundle.getFormattedString("shouldRestartTitle", [brandName]);
let shouldProceed = Services.prompt.confirm(window, title, msg)
if (shouldProceed) {
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
"restart");
shouldProceed = !cancelQuit.data;
if (shouldProceed) {
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
if (separateProfileModeCheckbox.checked) {
OS.File.remove(ignoreSeparateProfile).then(quitApp, revertCheckbox);
} else {
OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(quitApp, revertCheckbox);
}
}
}
// Revert the checkbox in case we didn't quit
revertCheckbox();
},
onGetStarted: function (aEvent) {
const Cc = Components.classes, Ci = Components.interfaces;
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
if (win) {
let accountsTab = win.gBrowser.addTab("about:accounts?action=migrateToDevEdition");
win.gBrowser.selectedTab = accountsTab;
}
},
#endif
// HOME PAGE
/*

Просмотреть файл

@ -77,17 +77,28 @@
<groupbox id="startupGroup">
<caption label="&startup.label;"/>
#ifdef MOZ_DEV_EDITION
<vbox id="separateProfileBox">
<checkbox id="separateProfileMode"
label="&separateProfileMode.label;"/>
<hbox align="center" class="indent">
<label id="useFirefoxSync">&useFirefoxSync.label;</label>
<label id="getStarted" class="text-link">&getStarted.label;</label>
</hbox>
</vbox>
#endif
#ifdef HAVE_SHELL_SERVICE
<vbox id="defaultBrowserBox">
<hbox align="center">
<checkbox id="alwaysCheckDefault" preference="browser.shell.checkDefaultBrowser"
label="&alwaysCheckDefault.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
label="&alwaysCheckDefault2.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
</hbox>
<deck id="setDefaultPane">
<hbox align="center" class="indent">
<label id="isNotDefaultLabel" flex="1">&isNotDefault.label;</label>
<button id="setDefaultButton"
label="&setAsMyDefaultBrowser.label;" accesskey="&setAsMyDefaultBrowser.accesskey;"
label="&setAsMyDefaultBrowser2.label;" accesskey="&setAsMyDefaultBrowser2.accesskey;"
oncommand="gMainPane.setDefaultBrowser();"
preference="pref.general.disable_button.default_browser"/>
</hbox>

Просмотреть файл

@ -594,7 +594,7 @@ let SessionStoreInternal = {
// manager message, so the target will be a <xul:browser>.
var browser = aMessage.target;
var win = browser.ownerDocument.defaultView;
let tab = this._getTabForBrowser(browser);
let tab = win.gBrowser.getTabForBrowser(browser);
if (!tab) {
// Ignore messages from <browser> elements that are not tabs.
return;
@ -2971,24 +2971,6 @@ let SessionStoreInternal = {
return window;
},
/**
* Gets the tab for the given browser. This should be marginally better
* than using tabbrowser's getTabForContentWindow. This assumes the browser
* is the linkedBrowser of a tab, not a dangling browser.
*
* @param aBrowser
* The browser from which to get the tab.
*/
_getTabForBrowser: function ssi_getTabForBrowser(aBrowser) {
let window = aBrowser.ownerDocument.defaultView;
for (let i = 0; i < window.gBrowser.tabs.length; i++) {
let tab = window.gBrowser.tabs[i];
if (tab.linkedBrowser == aBrowser)
return tab;
}
return undefined;
},
/**
* Whether or not to resume session, if not recovering from a crash.
* @returns bool

Просмотреть файл

@ -31,10 +31,13 @@
<!ENTITY alwaysAsk.label "Always ask me where to save files">
<!ENTITY alwaysAsk.accesskey "A">
<!ENTITY alwaysCheckDefault.label "Always check to see if &brandShortName; is the default browser on startup">
<!ENTITY alwaysCheckDefault2.label "Always check if &brandShortName; is your default browser">
<!ENTITY alwaysCheckDefault2.accesskey "w">
<!ENTITY setAsMyDefaultBrowser.label "Make &brandShortName; My Default Browser">
<!ENTITY setAsMyDefaultBrowser.accesskey "D">
<!ENTITY setAsMyDefaultBrowser2.label "Make Default">
<!ENTITY setAsMyDefaultBrowser2.accesskey "D">
<!ENTITY isDefault.label "&brandShortName; is currently your default browser">
<!ENTITY isNotDefault.label "&brandShortName; is not your default browser">
<!ENTITY separateProfileMode.label "Allow &brandShortName; and Firefox to run at the same time">
<!ENTITY useFirefoxSync.label "Tip: This uses separate profiles. Use Sync to share data between them.">
<!ENTITY getStarted.label "Start using Sync…">

Просмотреть файл

@ -55,6 +55,11 @@ label.small {
}
/* General Pane */
#useFirefoxSync,
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

Просмотреть файл

@ -169,6 +169,11 @@ caption {
/* General Pane */
#useFirefoxSync,
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

Просмотреть файл

@ -110,6 +110,15 @@ treecol {
/* General Pane */
#useFirefoxSync {
font-size: 90%;
-moz-margin-end: 8px !important;
}
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

Просмотреть файл

@ -55,6 +55,11 @@ label.small {
/* General Pane */
#useFirefoxSync,
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

Просмотреть файл

@ -108,6 +108,7 @@ function _setAppProperties(aObj, aApp) {
aObj.widgetPages = aApp.widgetPages || [];
aObj.kind = aApp.kind;
aObj.enabled = aApp.enabled !== undefined ? aApp.enabled : true;
aObj.sideloaded = aApp.sideloaded;
}
this.AppsUtils = {

Просмотреть файл

@ -115,8 +115,7 @@ MobileConnectionListener::NotifyDataError(const nsAString & message)
}
NS_IMETHODIMP
MobileConnectionListener::NotifyCFStateChanged(bool success,
uint16_t action,
MobileConnectionListener::NotifyCFStateChanged(uint16_t action,
uint16_t reason,
const nsAString& number,
uint16_t timeSeconds,

Просмотреть файл

@ -115,8 +115,7 @@ MobileConnectionListener::NotifyDataError(const nsAString & message)
}
NS_IMETHODIMP
MobileConnectionListener::NotifyCFStateChanged(bool success,
uint16_t action,
MobileConnectionListener::NotifyCFStateChanged(uint16_t action,
uint16_t reason,
const nsAString& number,
uint16_t timeSeconds,

Просмотреть файл

@ -9,6 +9,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=885996
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style> label { display: block } </style>
<script type="application/javascript;version=1.8">
/** Test the behaviour of the <input type='color'> when clicking on it from

Просмотреть файл

@ -39,40 +39,6 @@ namespace mozilla {
#ifdef MOZ_CHILD_PERMISSIONS
static bool
CheckAppTypeHelper(mozIApplication* aApp,
AssertAppProcessType aType,
const char* aCapability,
bool aIsBrowserElement)
{
bool aValid = false;
// isBrowser frames inherit their app descriptor to identify their
// data storage, but they don't inherit the capability associated
// with that descriptor.
if (aApp && (aType == ASSERT_APP_HAS_PERMISSION || !aIsBrowserElement)) {
switch (aType) {
case ASSERT_APP_HAS_PERMISSION:
case ASSERT_APP_PROCESS_PERMISSION:
if (!NS_SUCCEEDED(aApp->HasPermission(aCapability, &aValid))) {
aValid = false;
}
break;
case ASSERT_APP_PROCESS_MANIFEST_URL: {
nsAutoString manifestURL;
if (NS_SUCCEEDED(aApp->GetManifestURL(manifestURL)) &&
manifestURL.EqualsASCII(aCapability)) {
aValid = true;
}
break;
}
default:
break;
}
}
return aValid;
}
bool
AssertAppProcess(PBrowserParent* aActor,
AssertAppProcessType aType,
@ -85,24 +51,32 @@ AssertAppProcess(PBrowserParent* aActor,
TabParent* tab = static_cast<TabParent*>(aActor);
nsCOMPtr<mozIApplication> app = tab->GetOwnOrContainingApp();
bool aValid = false;
return CheckAppTypeHelper(app, aType, aCapability, tab->IsBrowserElement());
}
static bool
CheckAppStatusHelper(mozIApplication* aApp,
unsigned short aStatus)
{
bool valid = false;
if (aApp) {
unsigned short appStatus = 0;
if (NS_SUCCEEDED(aApp->GetAppStatus(&appStatus))) {
valid = appStatus == aStatus;
// isBrowser frames inherit their app descriptor to identify their
// data storage, but they don't inherit the capability associated
// with that descriptor.
if (app && (aType == ASSERT_APP_HAS_PERMISSION || !tab->IsBrowserElement())) {
switch (aType) {
case ASSERT_APP_HAS_PERMISSION:
case ASSERT_APP_PROCESS_PERMISSION:
if (!NS_SUCCEEDED(app->HasPermission(aCapability, &aValid))) {
aValid = false;
}
break;
case ASSERT_APP_PROCESS_MANIFEST_URL: {
nsAutoString manifestURL;
if (NS_SUCCEEDED(app->GetManifestURL(manifestURL)) &&
manifestURL.EqualsASCII(aCapability)) {
aValid = true;
}
break;
}
default:
break;
}
}
return valid;
return aValid;
}
bool
@ -117,26 +91,16 @@ AssertAppStatus(PBrowserParent* aActor,
TabParent* tab = static_cast<TabParent*>(aActor);
nsCOMPtr<mozIApplication> app = tab->GetOwnOrContainingApp();
return CheckAppStatusHelper(app, aStatus);
}
bool valid = false;
bool
AssertAppProcess(TabContext& aContext,
AssertAppProcessType aType,
const char* aCapability)
{
if (app) {
unsigned short appStatus = 0;
if (NS_SUCCEEDED(app->GetAppStatus(&appStatus))) {
valid = appStatus == aStatus;
}
}
nsCOMPtr<mozIApplication> app = aContext.GetOwnOrContainingApp();
return CheckAppTypeHelper(app, aType, aCapability, aContext.IsBrowserElement());
}
bool
AssertAppStatus(TabContext& aContext,
unsigned short aStatus)
{
nsCOMPtr<mozIApplication> app = aContext.GetOwnOrContainingApp();
return CheckAppStatusHelper(app, aStatus);
return valid;
}
bool
@ -144,10 +108,10 @@ AssertAppProcess(PContentParent* aActor,
AssertAppProcessType aType,
const char* aCapability)
{
nsTArray<TabContext> contextArray =
static_cast<ContentParent*>(aActor)->GetManagedTabContext();
for (uint32_t i = 0; i < contextArray.Length(); ++i) {
if (AssertAppProcess(contextArray[i], aType, aCapability)) {
const InfallibleTArray<PBrowserParent*>& browsers =
aActor->ManagedPBrowserParent();
for (uint32_t i = 0; i < browsers.Length(); ++i) {
if (AssertAppProcess(browsers[i], aType, aCapability)) {
return true;
}
}
@ -166,10 +130,10 @@ bool
AssertAppStatus(PContentParent* aActor,
unsigned short aStatus)
{
nsTArray<TabContext> contextArray =
static_cast<ContentParent*>(aActor)->GetManagedTabContext();
for (uint32_t i = 0; i < contextArray.Length(); ++i) {
if (AssertAppStatus(contextArray[i], aStatus)) {
const InfallibleTArray<PBrowserParent*>& browsers =
aActor->ManagedPBrowserParent();
for (uint32_t i = 0; i < browsers.Length(); ++i) {
if (AssertAppStatus(browsers[i], aStatus)) {
return true;
}
}
@ -206,13 +170,14 @@ AssertAppPrincipal(PContentParent* aActor,
bool inBrowserElement = aPrincipal->GetIsInBrowserElement();
// Check if the permission's appId matches a child we manage.
nsTArray<TabContext> contextArray =
static_cast<ContentParent*>(aActor)->GetManagedTabContext();
for (uint32_t i = 0; i < contextArray.Length(); ++i) {
if (contextArray[i].OwnOrContainingAppId() == principalAppId) {
const InfallibleTArray<PBrowserParent*>& browsers =
aActor->ManagedPBrowserParent();
for (uint32_t i = 0; i < browsers.Length(); ++i) {
TabParent* tab = static_cast<TabParent*>(browsers[i]);
if (tab->OwnOrContainingAppId() == principalAppId) {
// If the child only runs inBrowserElement content and the principal claims
// it's not in a browser element, it's lying.
if (!contextArray[i].IsBrowserElement() || inBrowserElement) {
if (!tab->IsBrowserElement() || inBrowserElement) {
return true;
}
break;
@ -322,21 +287,6 @@ AssertAppStatus(mozilla::dom::PBrowserParent* aActor,
return true;
}
bool
AssertAppProcess(const mozilla::dom::TabContext& aContext,
AssertAppProcessType aType,
const char* aCapability)
{
return true;
}
bool
AssertAppStatus(const mozilla::dom::TabContext& aContext,
unsigned short aStatus)
{
return true;
}
bool
AssertAppProcess(mozilla::dom::PContentParent* aActor,

Просмотреть файл

@ -15,7 +15,6 @@ class nsIPrincipal;
namespace mozilla {
namespace dom {
class TabContext;
class PBrowserParent;
class PContentParent;
}
@ -48,24 +47,6 @@ bool
AssertAppStatus(mozilla::dom::PBrowserParent* aActor,
unsigned short aStatus);
/**
* Return true if the specified browser has the specified capability.
* If this returns false, the browser didn't have the capability and
* will be killed.
*/
bool
AssertAppProcess(const mozilla::dom::TabContext& aContext,
AssertAppProcessType aType,
const char* aCapability);
/**
* Return true if the specified app has the specified status.
* If this returns false, the browser will be killed.
*/
bool
AssertAppStatus(const mozilla::dom::TabContext& aContext,
unsigned short aStatus);
/**
* Return true if any of the PBrowsers loaded in this content process
* has the specified capability. If this returns false, the process

Просмотреть файл

@ -81,18 +81,16 @@ ContentBridgeChild::SendPBlobConstructor(PBlobChild* actor,
bool
ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeChild::SendPBrowserConstructor(aActor,
aTabId,
aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}
@ -123,17 +121,15 @@ ContentBridgeChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
}
PBrowserChild*
ContentBridgeChild::AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext &aContext,
ContentBridgeChild::AllocPBrowserChild(const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentChild::AllocPBrowserChild(aTabId,
aContext,
return nsIContentChild::AllocPBrowserChild(aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}
@ -146,18 +142,16 @@ ContentBridgeChild::DeallocPBrowserChild(PBrowserChild* aChild)
bool
ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return ContentChild::GetSingleton()->RecvPBrowserConstructor(aActor,
aTabId,
aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}

Просмотреть файл

@ -39,28 +39,25 @@ public:
jsipc::JavaScriptShared* GetCPOWManager() MOZ_OVERRIDE;
virtual bool SendPBrowserConstructor(PBrowserChild* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
protected:
virtual ~ContentBridgeChild();
virtual PBrowserChild* AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserChild(PBrowserChild*) MOZ_OVERRIDE;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;

Просмотреть файл

@ -87,18 +87,16 @@ ContentBridgeParent::SendPBlobConstructor(PBlobParent* actor,
PBrowserParent*
ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentBridgeParent::SendPBrowserConstructor(aActor,
aTabId,
aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}
@ -128,17 +126,15 @@ ContentBridgeParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
}
PBrowserParent*
ContentBridgeParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext &aContext,
ContentBridgeParent::AllocPBrowserParent(const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aTabId,
aContext,
return nsIContentParent::AllocPBrowserParent(aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/dom/PContentBridgeParent.h"
#include "mozilla/dom/nsIContentParent.h"
#include "mozilla/dom/ipc/IdType.h"
namespace mozilla {
namespace dom {
@ -34,16 +33,15 @@ public:
virtual PBrowserParent*
SendPBrowserConstructor(PBrowserParent* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
jsipc::JavaScriptShared* GetCPOWManager() MOZ_OVERRIDE;
virtual ContentParentId ChildID() MOZ_OVERRIDE
virtual uint64_t ChildID() MOZ_OVERRIDE
{
return mChildID;
}
@ -59,7 +57,7 @@ public:
protected:
virtual ~ContentBridgeParent();
void SetChildID(ContentParentId aId)
void SetChildID(uint64_t aId)
{
mChildID = aId;
}
@ -88,10 +86,9 @@ protected:
DeallocPJavaScriptParent(jsipc::PJavaScriptParent*) MOZ_OVERRIDE;
virtual PBrowserParent*
AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext &aContext,
AllocPBrowserParent(const IPCTabContext &aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserParent(PBrowserParent*) MOZ_OVERRIDE;
@ -106,7 +103,7 @@ protected:
protected: // members
nsRefPtr<ContentBridgeParent> mSelfRef;
Transport* mTransport; // owned
ContentParentId mChildID;
uint64_t mChildID;
bool mIsForApp;
bool mIsForBrowser;

Просмотреть файл

@ -1109,45 +1109,40 @@ ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *aChild)
}
PBrowserChild*
ContentChild::AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
ContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentChild::AllocPBrowserChild(aTabId,
aContext,
return nsIContentChild::AllocPBrowserChild(aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}
bool
ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentChild::SendPBrowserConstructor(aActor,
aTabId,
aContext,
aChromeFlags,
aCpID,
aID,
aIsForApp,
aIsForBrowser);
}
bool
ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
@ -1171,7 +1166,7 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
// Redo InitProcessAttributes() when the app or browser is really
// launching so the attributes will be correct.
mID = aCpID;
mID = aID;
mIsForApp = aIsForApp;
mIsForBrowser = aIsForBrowser;
InitProcessAttributes();

Просмотреть файл

@ -131,10 +131,9 @@ public:
AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
MOZ_OVERRIDE;
virtual PBrowserChild* AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserChild(PBrowserChild*);
@ -355,7 +354,7 @@ public:
// cache the value
nsString &GetIndexedDBPath();
ContentParentId GetID() { return mID; }
uint64_t GetID() { return mID; }
bool IsForApp() { return mIsForApp; }
bool IsForBrowser() { return mIsForBrowser; }
@ -371,18 +370,16 @@ public:
DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*) MOZ_OVERRIDE;
virtual bool SendPBrowserConstructor(PBrowserChild* actor,
const TabId& aTabId,
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual PDocAccessibleChild* AllocPDocAccessibleChild(PDocAccessibleChild*, const uint64_t&) MOZ_OVERRIDE;
@ -415,7 +412,7 @@ private:
* We expect our content parent to set this ID immediately after opening a
* channel to us.
*/
ContentParentId mID;
uint64_t mID;
AppInfo mAppInfo;

Просмотреть файл

@ -131,7 +131,6 @@
#include "gfxPrefs.h"
#include "prio.h"
#include "private/pprio.h"
#include "ContentProcessManager.h"
#if defined(ANDROID) || defined(LINUX)
#include "nsSystemInfo.h"
@ -846,14 +845,17 @@ ContentParent::PreallocatedProcessReady()
#endif
}
typedef std::map<ContentParent*, std::set<ContentParent*> > GrandchildMap;
static GrandchildMap sGrandchildProcessMap;
std::map<uint64_t, ContentParent*> sContentParentMap;
bool
ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
uint64_t* aId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId)
bool* aIsForBrowser)
{
#if 0
if (!CanOpenBrowser(aContext)) {
@ -882,67 +884,40 @@ ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
}
if (!cp) {
*aCpId = 0;
*aId = 0;
*aIsForApp = false;
*aIsForBrowser = false;
return true;
}
*aCpId = cp->ChildID();
*aId = cp->ChildID();
*aIsForApp = cp->IsForApp();
*aIsForBrowser = cp->IsForBrowser();
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
cpm->AddContentProcess(cp, this->ChildID());
if (cpm->AddGrandchildProcess(this->ChildID(), cp->ChildID())) {
// Pre-allocate a TabId here to save one time IPC call at app startup.
*aTabId = AllocateTabId(aOpenerTabId,
aContext,
cp->ChildID());
return (*aTabId != 0);
sContentParentMap[*aId] = cp;
auto iter = sGrandchildProcessMap.find(this);
if (iter == sGrandchildProcessMap.end()) {
std::set<ContentParent*> children;
children.insert(cp);
sGrandchildProcessMap[this] = children;
} else {
iter->second.insert(cp);
}
return false;
return true;
}
bool
ContentParent::AnswerBridgeToChildProcess(const ContentParentId& aCpId)
ContentParent::AnswerBridgeToChildProcess(const uint64_t& id)
{
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
ContentParent* cp = cpm->GetContentProcessById(aCpId);
if (cp) {
ContentParentId parentId;
if (cpm->GetParentProcessId(cp->ChildID(), &parentId) &&
parentId == this->ChildID()) {
return PContentBridge::Bridge(this, cp);
}
ContentParent* cp = sContentParentMap[id];
auto iter = sGrandchildProcessMap.find(this);
if (iter != sGrandchildProcessMap.end() &&
iter->second.find(cp) != iter->second.end()) {
return PContentBridge::Bridge(this, cp);
} else {
// You can't bridge to a process you didn't open!
KillHard();
return false;
}
// You can't bridge to a process you didn't open!
KillHard();
return false;
}
static nsIDocShell* GetOpenerDocShellHelper(Element* aFrameElement)
{
// Propagate the private-browsing status of the element's parent
// docshell to the remote docshell, via the chrome flags.
nsCOMPtr<Element> frameElement = do_QueryInterface(aFrameElement);
MOZ_ASSERT(frameElement);
nsPIDOMWindow* win = frameElement->OwnerDoc()->GetWindow();
if (!win) {
NS_WARNING("Remote frame has no window");
return nullptr;
}
nsIDocShell* docShell = win->GetDocShell();
if (!docShell) {
NS_WARNING("Remote frame has no docshell");
return nullptr;
}
return docShell;
}
/*static*/ TabParent*
@ -956,38 +931,40 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
bool isInContentProcess = (XRE_GetProcessType() != GeckoProcessType_Default);
TabId tabId;
nsIDocShell* docShell = GetOpenerDocShellHelper(aFrameElement);
TabId openerTabId;
if (docShell) {
openerTabId = TabParent::GetTabIdFrom(docShell);
}
if (aContext.IsBrowserElement() || !aContext.HasOwnApp()) {
nsRefPtr<TabParent> tp;
nsRefPtr<nsIContentParent> constructorSender;
if (isInContentProcess) {
MOZ_ASSERT(aContext.IsBrowserElement());
constructorSender = CreateContentBridgeParent(aContext,
initialPriority,
openerTabId,
&tabId);
constructorSender =
CreateContentBridgeParent(aContext, initialPriority);
} else {
if (aOpenerContentParent) {
constructorSender = aOpenerContentParent;
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
initialPriority);
}
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
constructorSender->ChildID());
if (aOpenerContentParent) {
constructorSender = aOpenerContentParent;
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
initialPriority);
}
}
if (constructorSender) {
uint32_t chromeFlags = 0;
// Propagate the private-browsing status of the element's parent
// docshell to the remote docshell, via the chrome flags.
nsCOMPtr<Element> frameElement = do_QueryInterface(aFrameElement);
MOZ_ASSERT(frameElement);
nsPIDOMWindow* win = frameElement->OwnerDoc()->GetWindow();
if (!win) {
NS_WARNING("Remote frame has no window");
return nullptr;
}
nsIDocShell* docShell = win->GetDocShell();
if (!docShell) {
NS_WARNING("Remote frame has no docshell");
return nullptr;
}
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext && loadContext->UsePrivateBrowsing()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
@ -998,17 +975,13 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}
if (tabId == 0) {
return nullptr;
}
nsRefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
nsRefPtr<TabParent> tp(new TabParent(constructorSender,
aContext, chromeFlags));
tp->SetOwnerElement(aFrameElement);
PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
tp.forget().take(),
tabId,
aContext.AsIPCTabContext(),
chromeFlags,
constructorSender->ChildID(),
@ -1028,10 +1001,7 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
nsAutoString manifestURL;
if (isInContentProcess) {
parent = CreateContentBridgeParent(aContext,
initialPriority,
openerTabId,
&tabId);
parent = CreateContentBridgeParent(aContext, initialPriority);
}
else {
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
@ -1079,9 +1049,6 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
// Check if we can re-use the process of the parent app.
p = sAppContentParents->Get(parentAppManifestURL);
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
p->ChildID());
}
}
}
@ -1103,25 +1070,21 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
&tookPreallocated);
MOZ_ASSERT(p);
sAppContentParents->Put(manifestURL, p);
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
p->ChildID());
}
parent = static_cast<nsIContentParent*>(p);
}
if (!parent || (tabId == 0)) {
if (!parent) {
return nullptr;
}
uint32_t chromeFlags = 0;
nsRefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
nsRefPtr<TabParent> tp = new TabParent(parent, aContext, chromeFlags);
tp->SetOwnerElement(aFrameElement);
PBrowserParent* browser = parent->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
nsRefPtr<TabParent>(tp).forget().take(),
tabId,
aContext.AsIPCTabContext(),
chromeFlags,
parent->ChildID(),
@ -1164,33 +1127,27 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
/*static*/ ContentBridgeParent*
ContentParent::CreateContentBridgeParent(const TabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
/*out*/ TabId* aTabId)
const hal::ProcessPriority& aPriority)
{
MOZ_ASSERT(aTabId);
ContentChild* child = ContentChild::GetSingleton();
ContentParentId cpId;
uint64_t id;
bool isForApp;
bool isForBrowser;
if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
aPriority,
aOpenerTabId,
&cpId,
&id,
&isForApp,
&isForBrowser,
aTabId)) {
&isForBrowser)) {
return nullptr;
}
if (cpId == 0) {
if (id == 0) {
return nullptr;
}
if (!child->CallBridgeToChildProcess(cpId)) {
if (!child->CallBridgeToChildProcess(id)) {
return nullptr;
}
ContentBridgeParent* parent = child->GetLastBridge();
parent->SetChildID(cpId);
parent->SetChildID(id);
parent->SetIsForApp(isForApp);
parent->SetIsForBrowser(isForBrowser);
return parent;
@ -1519,6 +1476,13 @@ ContentParent::MarkAsDead()
}
mIsAlive = false;
sGrandchildProcessMap.erase(this);
for (auto iter = sGrandchildProcessMap.begin();
iter != sGrandchildProcessMap.end();
iter++) {
iter->second.erase(this);
}
}
void
@ -1756,17 +1720,17 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this));
// Destroy any processes created by this ContentParent
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
nsTArray<ContentParentId> childIDArray =
cpm->GetAllChildProcessById(this->ChildID());
for(uint32_t i = 0; i < childIDArray.Length(); i++) {
ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
/* closeWithError */ false));
auto iter = sGrandchildProcessMap.find(this);
if (iter != sGrandchildProcessMap.end()) {
for(auto child = iter->second.begin();
child != iter->second.end();
child++) {
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(*child, &ContentParent::ShutDownProcess,
/* closeWithError */ false));
}
}
cpm->RemoveContentProcess(this->ChildID());
}
void
@ -1929,8 +1893,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
InitInternal(aInitialPriority,
true, /* Setup off-main thread compositing */
true /* Send registered chrome */);
ContentProcessManager::GetSingleton()->AddContentProcess(this);
}
#ifdef MOZ_NUWA_PROCESS
@ -2008,8 +1970,6 @@ ContentParent::ContentParent(ContentParent* aTemplate,
InitInternal(priority,
false, /* Setup Off-main thread compositing */
false /* Send registered chrome */);
ContentProcessManager::GetSingleton()->AddContentProcess(this);
}
#endif // MOZ_NUWA_PROCESS
@ -2820,10 +2780,10 @@ ContentParent::AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTranspo
}
bool
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
ContentParent::RecvGetProcessAttributes(uint64_t* aId,
bool* aIsForApp, bool* aIsForBrowser)
{
*aCpId = mChildID;
*aId = mChildID;
*aIsForApp = IsForApp();
*aIsForBrowser = mIsForBrowser;
@ -2871,17 +2831,15 @@ ContentParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
}
PBrowserParent*
ContentParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
ContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aTabId,
aContext,
return nsIContentParent::AllocPBrowserParent(aContext,
aChromeFlags,
aCpId,
aId,
aIsForApp,
aIsForBrowser);
}
@ -3867,18 +3825,16 @@ ContentParent::RecvSystemMessageHandled()
PBrowserParent*
ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentParent::SendPBrowserConstructor(aActor,
aTabId,
aContext,
aChromeFlags,
aCpId,
aId,
aIsForApp,
aIsForBrowser);
}
@ -4177,66 +4133,6 @@ ContentParent::NotifyUpdatedDictionaries()
}
}
/*static*/ TabId
ContentParent::AllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aCpId)
{
TabId tabId;
if (XRE_GetProcessType() == GeckoProcessType_Default) {
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
tabId = cpm->AllocateTabId(aOpenerTabId, aContext, aCpId);
}
else {
ContentChild::GetSingleton()->SendAllocateTabId(aOpenerTabId,
aContext,
aCpId,
&tabId);
}
return tabId;
}
/*static*/ void
ContentParent::DeallocateTabId(const TabId& aTabId,
const ContentParentId& aCpId)
{
if (XRE_GetProcessType() == GeckoProcessType_Default) {
ContentProcessManager::GetSingleton()->DeallocateTabId(aCpId,
aTabId);
}
else {
ContentChild::GetSingleton()->SendDeallocateTabId(aTabId);
}
}
bool
ContentParent::RecvAllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aCpId,
TabId* aTabId)
{
*aTabId = AllocateTabId(aOpenerTabId, aContext, aCpId);
if (!(*aTabId)) {
return false;
}
return true;
}
bool
ContentParent::RecvDeallocateTabId(const TabId& aTabId)
{
DeallocateTabId(aTabId, this->ChildID());
return true;
}
nsTArray<TabContext>
ContentParent::GetManagedTabContext()
{
return Move(ContentProcessManager::GetSingleton()->
GetTabContextByContentProcess(this->ChildID()));
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -143,12 +143,10 @@ public:
virtual bool RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
uint64_t* aId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId) MOZ_OVERRIDE;
virtual bool AnswerBridgeToChildProcess(const ContentParentId& aCpId) MOZ_OVERRIDE;
bool* aIsForBrowser) MOZ_OVERRIDE;
virtual bool AnswerBridgeToChildProcess(const uint64_t& id) MOZ_OVERRIDE;
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ContentParent, nsIObserver)
@ -181,13 +179,6 @@ public:
TestShellParent* GetTestShellSingleton();
jsipc::JavaScriptShared* GetCPOWManager() MOZ_OVERRIDE;
static TabId
AllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aCpId);
static void
DeallocateTabId(const TabId& aTabId, const ContentParentId& aCpId);
void ReportChildAlreadyBlocked();
bool RequestRunToCompletion();
@ -226,7 +217,7 @@ public:
*/
void KillHard();
ContentParentId ChildID() MOZ_OVERRIDE { return mChildID; }
uint64_t ChildID() MOZ_OVERRIDE { return mChildID; }
const nsString& AppManifestURL() const { return mAppManifestURL; }
bool IsPreallocated();
@ -291,14 +282,6 @@ public:
PBlobParent* aActor,
const BlobConstructorParams& aParams) MOZ_OVERRIDE;
virtual bool RecvAllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aCpId,
TabId* aTabId) MOZ_OVERRIDE;
virtual bool RecvDeallocateTabId(const TabId& aTabId) MOZ_OVERRIDE;
nsTArray<TabContext> GetManagedTabContext();
protected:
void OnChannelConnected(int32_t pid) MOZ_OVERRIDE;
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
@ -327,18 +310,15 @@ private:
static hal::ProcessPriority GetInitialProcessPriority(Element* aFrameElement);
static ContentBridgeParent* CreateContentBridgeParent(const TabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
/*out*/ TabId* aTabId);
const hal::ProcessPriority& aPriority);
// Hide the raw constructor methods since we don't want client code
// using them.
virtual PBrowserParent* SendPBrowserConstructor(
PBrowserParent* actor,
const TabId& aTabId,
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
using PContentParent::SendPTestShellConstructor;
@ -429,7 +409,7 @@ private:
AllocPBackgroundParent(Transport* aTransport, ProcessId aOtherProcess)
MOZ_OVERRIDE;
virtual bool RecvGetProcessAttributes(ContentParentId* aCpId,
virtual bool RecvGetProcessAttributes(uint64_t* aId,
bool* aIsForApp,
bool* aIsForBrowser) MOZ_OVERRIDE;
virtual bool RecvGetXPCOMProcessAttributes(bool* aIsOffline,
@ -440,10 +420,9 @@ private:
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) MOZ_OVERRIDE;
virtual bool DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent*) MOZ_OVERRIDE;
virtual PBrowserParent* AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
virtual PBrowserParent* AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserParent(PBrowserParent* frame) MOZ_OVERRIDE;
@ -713,7 +692,7 @@ private:
GeckoChildProcessHost* mSubprocess;
ContentParent* mOpener;
ContentParentId mChildID;
uint64_t mChildID;
int32_t mGeolocationWatchID;
nsString mAppManifestURL;

Просмотреть файл

@ -1,276 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et ft=cpp : */
/* 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/. */
#include "ContentProcessManager.h"
#include "ContentParent.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/ClearOnShutdown.h"
#include "nsPrintfCString.h"
// XXX need another bug to move this to a common header.
#ifdef DISABLE_ASSERTS_FOR_FUZZING
#define ASSERT_UNLESS_FUZZING(...) do { } while (0)
#else
#define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false, __VA_ARGS__)
#endif
namespace mozilla {
namespace dom {
static uint64_t gTabId = 0;
/* static */
StaticAutoPtr<ContentProcessManager>
ContentProcessManager::sSingleton;
/* static */ ContentProcessManager*
ContentProcessManager::GetSingleton()
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
if (!sSingleton) {
sSingleton = new ContentProcessManager();
ClearOnShutdown(&sSingleton);
}
return sSingleton;
}
void
ContentProcessManager::AddContentProcess(ContentParent* aChildCp,
const ContentParentId& aParentCpId)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aChildCp);
ContentProcessInfo info;
info.mCp = aChildCp;
info.mParentCpId = aParentCpId;
mContentParentMap[aChildCp->ChildID()] = info;
}
void
ContentProcessManager::RemoveContentProcess(const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mContentParentMap.find(aChildCpId) != mContentParentMap.end());
mContentParentMap.erase(aChildCpId);
for (auto iter = mContentParentMap.begin();
iter != mContentParentMap.end();
++iter) {
if (!iter->second.mChildrenCpId.empty()) {
iter->second.mChildrenCpId.erase(aChildCpId);
}
}
}
bool
ContentProcessManager::AddGrandchildProcess(const ContentParentId& aParentCpId,
const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
auto iter = mContentParentMap.find(aParentCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING("Parent process should be already in map!");
return false;
}
iter->second.mChildrenCpId.insert(aChildCpId);
return true;
}
bool
ContentProcessManager::GetParentProcessId(const ContentParentId& aChildCpId,
/*out*/ ContentParentId* aParentCpId)
{
MOZ_ASSERT(NS_IsMainThread());
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return false;
}
*aParentCpId = iter->second.mParentCpId;
return true;
}
ContentParent*
ContentProcessManager::GetContentProcessById(const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return nullptr;
}
return iter->second.mCp;
}
nsTArray<ContentParentId>
ContentProcessManager::GetAllChildProcessById(const ContentParentId& aParentCpId)
{
MOZ_ASSERT(NS_IsMainThread());
nsTArray<ContentParentId> cpIdArray;
auto iter = mContentParentMap.find(aParentCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return Move(cpIdArray);
}
for (auto cpIter = iter->second.mChildrenCpId.begin();
cpIter != iter->second.mChildrenCpId.end();
++cpIter) {
cpIdArray.AppendElement(*cpIter);
}
return Move(cpIdArray);
}
TabId
ContentProcessManager::AllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return TabId(0);
}
struct RemoteFrameInfo info;
const IPCTabAppBrowserContext& appBrowser = aContext.appBrowserContext();
// If it's a PopupIPCTabContext, it's the case that a TabChild want to
// open a new tab. aOpenerTabId has to be it's parent frame's opener id.
if (appBrowser.type() == IPCTabAppBrowserContext::TPopupIPCTabContext) {
auto remoteFrameIter = iter->second.mRemoteFrames.find(aOpenerTabId);
if (remoteFrameIter == iter->second.mRemoteFrames.end()) {
ASSERT_UNLESS_FUZZING("Failed to find parent frame's opener id.");
return TabId(0);
}
info.mOpenerTabId = remoteFrameIter->second.mOpenerTabId;
const PopupIPCTabContext &ipcContext = appBrowser.get_PopupIPCTabContext();
MOZ_ASSERT(ipcContext.opener().type() == PBrowserOrId::TTabId);
remoteFrameIter = iter->second.mRemoteFrames.find(ipcContext.opener().get_TabId());
if (remoteFrameIter == iter->second.mRemoteFrames.end()) {
ASSERT_UNLESS_FUZZING("Failed to find tab id.");
return TabId(0);
}
info.mContext = remoteFrameIter->second.mContext;
}
else {
MaybeInvalidTabContext tc(aContext);
if (!tc.IsValid()) {
NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
"the child process. (%s)",
tc.GetInvalidReason()).get());
return TabId(0);
}
info.mOpenerTabId = aOpenerTabId;
info.mContext = tc.GetTabContext();
}
mUniqueId = ++gTabId;
iter->second.mRemoteFrames[mUniqueId] = info;
return mUniqueId;
}
void
ContentProcessManager::DeallocateTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId)
{
MOZ_ASSERT(NS_IsMainThread());
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return;
}
auto remoteFrameIter = iter->second.mRemoteFrames.find(aChildTabId);
if (remoteFrameIter != iter->second.mRemoteFrames.end()) {
iter->second.mRemoteFrames.erase(aChildTabId);
}
}
nsTArray<uint64_t>
ContentProcessManager::GetAppIdsByContentProcess(const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
nsTArray<uint64_t> appIdArray;
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return Move(appIdArray);
}
for (auto remoteFrameIter = iter->second.mRemoteFrames.begin();
remoteFrameIter != iter->second.mRemoteFrames.end();
++remoteFrameIter) {
appIdArray.AppendElement(remoteFrameIter->second.mContext.OwnOrContainingAppId());
}
return Move(appIdArray);
}
nsTArray<TabContext>
ContentProcessManager::GetTabContextByContentProcess(const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
nsTArray<TabContext> tabContextArray;
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return Move(tabContextArray);
}
for (auto remoteFrameIter = iter->second.mRemoteFrames.begin();
remoteFrameIter != iter->second.mRemoteFrames.end();
++remoteFrameIter) {
tabContextArray.AppendElement(remoteFrameIter->second.mContext);
}
return Move(tabContextArray);
}
bool
ContentProcessManager::GetRemoteFrameOpenerTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId,
/*out*/TabId* aOpenerTabId)
{
MOZ_ASSERT(NS_IsMainThread());
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return false;
}
auto remoteFrameIter = iter->second.mRemoteFrames.find(aChildTabId);
if (NS_WARN_IF(remoteFrameIter == iter->second.mRemoteFrames.end())) {
ASSERT_UNLESS_FUZZING();
return false;
}
*aOpenerTabId = remoteFrameIter->second.mOpenerTabId;
return true;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,122 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et ft=cpp : */
/* 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/. */
#ifndef mozilla_dom_ContentProcessManager_h
#define mozilla_dom_ContentProcessManager_h
#include <map>
#include <set>
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/TabContext.h"
#include "mozilla/dom/ipc/IdType.h"
#include "nsTArray.h"
namespace mozilla {
namespace dom {
class ContentParent;
struct RemoteFrameInfo
{
TabId mOpenerTabId;
TabContext mContext;
};
struct ContentProcessInfo
{
ContentParent* mCp;
ContentParentId mParentCpId;
std::set<ContentParentId> mChildrenCpId;
std::map<TabId, RemoteFrameInfo> mRemoteFrames;
};
class ContentProcessManager MOZ_FINAL
{
public:
static ContentProcessManager* GetSingleton();
~ContentProcessManager() {MOZ_COUNT_DTOR(ContentProcessManager);};
/**
* Add a new content process into the map.
* If aParentCpId is not 0, it's a nested content process.
*/
void AddContentProcess(ContentParent* aChildCp,
const ContentParentId& aParentCpId = ContentParentId(0));
/**
* Remove the content process by id.
*/
void RemoveContentProcess(const ContentParentId& aChildCpId);
/**
* Add a grandchild content process into the map.
* aParentCpId must be already added in the map by AddContentProcess().
*/
bool AddGrandchildProcess(const ContentParentId& aParentCpId,
const ContentParentId& aChildCpId);
/**
* Get the parent process's id by child process's id.
* Used to check if a child really belongs to the parent.
*/
bool GetParentProcessId(const ContentParentId& aChildCpId,
/*out*/ ContentParentId* aParentCpId);
/**
* Return the ContentParent pointer by id.
*/
ContentParent* GetContentProcessById(const ContentParentId& aChildCpId);
/**
* Return a list of all child process's id.
*/
nsTArray<ContentParentId>
GetAllChildProcessById(const ContentParentId& aParentCpId);
/**
* Allocate a tab id for the given content process's id.
* Used when a content process wants to create a new tab. aOpenerTabId and
* aContext are saved in RemoteFrameInfo, which is a part of ContentProcessInfo.
* We can use the tab id and process id to locate the TabContext for future use.
*/
TabId AllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aChildCpId);
/**
* Remove the RemoteFrameInfo by the given process and tab id.
*/
void DeallocateTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId);
/**
* Get all app ids which are inside the given content process.
* XXX Currently not used. Plan to be used for bug 1020186.
*/
nsTArray<uint64_t>
GetAppIdsByContentProcess(const ContentParentId& aChildCpId);
/**
* Get all TabContext which are inside the given content process.
* Used for AppProcessChecker to cehck app status.
*/
nsTArray<TabContext>
GetTabContextByContentProcess(const ContentParentId& aChildCpId);
/**
* Query a tab's opener id by the given process and tab id.
* XXX Currently not used. Plan to be used for bug 1020179.
*/
bool GetRemoteFrameOpenerTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId,
/*out*/ TabId* aOpenerTabId);
private:
static StaticAutoPtr<ContentProcessManager> sSingleton;
TabId mUniqueId;
std::map<ContentParentId, ContentProcessInfo> mContentParentMap;
ContentProcessManager() {MOZ_COUNT_CTOR(ContentProcessManager);};
};
} // namespace dom
} // namespace mozilla
#endif

Просмотреть файл

@ -1,74 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* 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/. */
#ifndef mozilla_dom_IdType_h
#define mozilla_dom_IdType_h
#include "ipc/IPCMessageUtils.h"
namespace IPC {
template<typename T> struct ParamTraits;
}
namespace mozilla {
namespace dom {
class ContentParent;
class TabParent;
template<typename T>
class IdType
{
friend struct IPC::ParamTraits<IdType<T>>;
public:
IdType() : mId(0) {}
explicit IdType(uint64_t aId) : mId(aId) {}
operator uint64_t() const { return mId; }
IdType& operator=(uint64_t aId)
{
mId = aId;
return *this;
}
bool operator<(const IdType& rhs)
{
return mId < rhs.mId;
}
private:
uint64_t mId;
};
typedef IdType<TabParent> TabId;
typedef IdType<ContentParent> ContentParentId;
} // namespace dom
} // namespace mozilla
namespace IPC {
template<typename T>
struct ParamTraits<mozilla::dom::IdType<T>>
{
typedef mozilla::dom::IdType<T> paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mId);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return ReadParam(aMsg, aIter, &aResult->mId);
}
};
}
#endif

Просмотреть файл

@ -1,21 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=c: */
/* 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/. */
include protocol PBrowser;
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
namespace mozilla {
namespace dom {
union PBrowserOrId
{
nullable PBrowser;
TabId;
};
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -67,8 +67,6 @@ using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::dom::quota::PersistenceType from "mozilla/dom/quota/PersistenceType.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using gfxIntSize from "nsSize.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
union ChromeRegistryItem
{
@ -387,8 +385,8 @@ both:
// access to (in the form of a TabChild).
//
// Keep the last 3 attributes in sync with GetProcessAttributes!
async PBrowser(TabId tabId, IPCTabContext context, uint32_t chromeFlags,
ContentParentId cpId, bool isForApp, bool isForBrowser);
async PBrowser(IPCTabContext context, uint32_t chromeFlags,
uint64_t id, bool isForApp, bool isForBrowser);
async PBlob(BlobConstructorParams params);
@ -522,16 +520,15 @@ parent:
* Keep the return values in sync with PBrowser()!
*/
sync GetProcessAttributes()
returns (ContentParentId cpId, bool isForApp, bool isForBrowser);
returns (uint64_t id, bool isForApp, bool isForBrowser);
sync GetXPCOMProcessAttributes()
returns (bool isOffline, nsString[] dictionaries,
ClipboardCapabilities clipboardCaps);
sync CreateChildProcess(IPCTabContext context,
ProcessPriority priority,
TabId openerTabId)
returns (ContentParentId cpId, bool isForApp, bool isForBrowser, TabId tabId);
intr BridgeToChildProcess(ContentParentId cpId);
ProcessPriority priority)
returns (uint64_t id, bool isForApp, bool isForBrowser);
intr BridgeToChildProcess(uint64_t id);
async PJavaScript();
@ -746,14 +743,6 @@ parent:
returns (int32_t refCnt, int32_t dBRefCnt, int32_t sliceRefCnt,
bool result);
/**
* Tell the chrome process there is an creation of PBrowser.
* return a system-wise unique Id.
*/
sync AllocateTabId(TabId openerTabId, IPCTabContext context, ContentParentId cpId)
returns (TabId tabId);
async DeallocateTabId(TabId tabId);
both:
AsyncMessage(nsString aMessage, ClonedMessageData aData,
CpowEntry[] aCpows, Principal aPrincipal);

Просмотреть файл

@ -14,8 +14,6 @@ include JavaScriptTypes;
include PTabContext;
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
namespace mozilla {
namespace dom {
@ -43,8 +41,8 @@ parent:
both:
// Both the parent and the child can construct the PBrowser.
// See the comment in PContent::PBrowser().
async PBrowser(TabId tabId, IPCTabContext context, uint32_t chromeFlags,
ContentParentId cpId, bool isForApp, bool isForBrowser);
async PBrowser(IPCTabContext context, uint32_t chromeFlags,
uint64_t id, bool isForApp, bool isForBrowser);
async PBlob(BlobConstructorParams params);

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBrowser;
include PBrowserOrId;
using mozilla::layout::ScrollingBehavior from "mozilla/layout/RenderFrameUtils.h";
@ -27,7 +27,7 @@ namespace dom {
// it.
struct PopupIPCTabContext
{
PBrowserOrId opener;
PBrowser opener;
bool isBrowserElement;
};

Просмотреть файл

@ -472,15 +472,14 @@ ProcessPriorityManagerImpl::GetParticularProcessPriorityManager(
ContentParent* aContentParent)
{
nsRefPtr<ParticularProcessPriorityManager> pppm;
uint64_t cpId = aContentParent->ChildID();
mParticularManagers.Get(cpId, &pppm);
mParticularManagers.Get(aContentParent->ChildID(), &pppm);
if (!pppm) {
pppm = new ParticularProcessPriorityManager(aContentParent);
pppm->Init();
mParticularManagers.Put(cpId, pppm);
mParticularManagers.Put(aContentParent->ChildID(), pppm);
FireTestOnlyObserverNotification("process-created",
nsPrintfCString("%lld", cpId));
nsPrintfCString("%lld", aContentParent->ChildID()));
}
return pppm.forget();

Просмотреть файл

@ -733,11 +733,11 @@ private:
StaticRefPtr<TabChild> sPreallocatedTab;
/*static*/
std::map<TabId, nsRefPtr<TabChild>>&
std::map<uint64_t, nsRefPtr<TabChild> >&
TabChild::NestedTabChildMap()
{
MOZ_ASSERT(NS_IsMainThread());
static std::map<TabId, nsRefPtr<TabChild>> sNestedTabChildMap;
static std::map<uint64_t, nsRefPtr<TabChild> > sNestedTabChildMap;
return sNestedTabChildMap;
}
@ -750,7 +750,6 @@ TabChild::PreloadSlowThings()
// not connected to any manager. Any attempt to use the TabChild
// in IPC will crash.
nsRefPtr<TabChild> tab(new TabChild(nullptr,
TabId(0),
TabContext(), /* chromeFlags */ 0));
if (!NS_SUCCEEDED(tab->Init()) ||
!tab->InitTabChildGlobal(DONT_LOAD_SCRIPTS)) {
@ -781,7 +780,6 @@ TabChild::PreloadSlowThings()
/*static*/ already_AddRefed<TabChild>
TabChild::Create(nsIContentChild* aManager,
const TabId& aTabId,
const TabContext &aContext,
uint32_t aChromeFlags)
{
@ -795,20 +793,18 @@ TabChild::Create(nsIContentChild* aManager,
MOZ_ASSERT(!child->mTriedBrowserInit);
child->mManager = aManager;
child->SetTabId(aTabId);
child->SetTabContext(aContext);
child->NotifyTabContextUpdated();
return child.forget();
}
nsRefPtr<TabChild> iframe = new TabChild(aManager, aTabId,
nsRefPtr<TabChild> iframe = new TabChild(aManager,
aContext, aChromeFlags);
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget() : nullptr;
}
TabChild::TabChild(nsIContentChild* aManager,
const TabId& aTabId,
const TabContext& aContext,
uint32_t aChromeFlags)
: TabContext(aContext)
@ -832,8 +828,8 @@ TabChild::TabChild(nsIContentChild* aManager,
, mIgnoreKeyPressEvent(false)
, mActiveElementManager(new ActiveElementManager())
, mHasValidInnerSize(false)
, mUniqueId(0)
, mDestroyed(false)
, mUniqueId(aTabId)
{
if (!sActiveDurationMsSet) {
Preferences::AddIntVarCache(&sActiveDurationMs,
@ -841,12 +837,6 @@ TabChild::TabChild(nsIContentChild* aManager,
sActiveDurationMs);
sActiveDurationMsSet = true;
}
// preloaded TabChild should not be added to child map
if (mUniqueId) {
MOZ_ASSERT(NestedTabChildMap().find(mUniqueId) == NestedTabChildMap().end());
NestedTabChildMap()[mUniqueId] = this;
}
}
NS_IMETHODIMP
@ -1444,36 +1434,26 @@ TabChild::BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
{
*aReturn = nullptr;
ContentChild* cc = ContentChild::GetSingleton();
const TabId openerTabId = GetTabId();
nsRefPtr<TabChild> newChild =
new TabChild(ContentChild::GetSingleton(),
/* TabContext */ *this, /* chromeFlags */ 0);
if (!NS_SUCCEEDED(newChild->Init())) {
return NS_ERROR_ABORT;
}
// We must use PopupIPCTabContext here; ContentParent will not accept the
// result of this->AsIPCTabContext() (which will be a
// BrowserFrameIPCTabContext or an AppFrameIPCTabContext), for security
// reasons.
PopupIPCTabContext context;
context.opener() = openerTabId;
context.openerChild() = this;
context.isBrowserElement() = IsBrowserElement();
IPCTabContext ipcContext(context, mScrolling);
TabId tabId;
cc->SendAllocateTabId(openerTabId,
ipcContext,
cc->GetID(),
&tabId);
nsRefPtr<TabChild> newChild = new TabChild(ContentChild::GetSingleton(), tabId,
/* TabContext */ *this, /* chromeFlags */ 0);
if (NS_FAILED(newChild->Init())) {
return NS_ERROR_ABORT;
}
context.opener() = this;
ContentChild* cc = static_cast<ContentChild*>(Manager());
unused << Manager()->SendPBrowserConstructor(
// We release this ref in DeallocPBrowserChild
nsRefPtr<TabChild>(newChild).forget().take(),
tabId, IPCTabContext(context, mScrolling), /* chromeFlags */ 0,
IPCTabContext(context, mScrolling), /* chromeFlags */ 0,
cc->GetID(), cc->IsForApp(), cc->IsForBrowser());
nsAutoCString spec;
@ -1583,8 +1563,8 @@ TabChild::ActorDestroy(ActorDestroyReason why)
CompositorChild* compositorChild = static_cast<CompositorChild*>(CompositorChild::Get());
compositorChild->CancelNotifyAfterRemotePaint(this);
if (GetTabId() != 0) {
NestedTabChildMap().erase(GetTabId());
if (Id() != 0) {
NestedTabChildMap().erase(Id());
}
}

Просмотреть файл

@ -34,7 +34,6 @@
#include "mozilla/EventForwards.h"
#include "mozilla/layers/CompositorTypes.h"
#include "nsIWebBrowserChrome3.h"
#include "mozilla/dom/ipc/IdType.h"
class nsICachedFileDescriptorListener;
class nsIDOMWindowUtils;
@ -255,7 +254,7 @@ class TabChild MOZ_FINAL : public TabChildBase,
typedef mozilla::layers::ActiveElementManager ActiveElementManager;
public:
static std::map<TabId, nsRefPtr<TabChild>>& NestedTabChildMap();
static std::map<uint64_t, nsRefPtr<TabChild> >& NestedTabChildMap();
public:
/**
@ -267,13 +266,26 @@ public:
/** Return a TabChild with the given attributes. */
static already_AddRefed<TabChild>
Create(nsIContentChild* aManager, const TabId& aTabId, const TabContext& aContext, uint32_t aChromeFlags);
Create(nsIContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags);
bool IsRootContentDocument();
const TabId GetTabId() const {
MOZ_ASSERT(mUniqueId != 0);
return mUniqueId;
const uint64_t Id() const {
return mUniqueId;
}
static uint64_t
GetTabChildId(TabChild* aTabChild)
{
MOZ_ASSERT(NS_IsMainThread());
if (aTabChild->Id() != 0) {
return aTabChild->Id();
}
static uint64_t sId = 0;
sId++;
aTabChild->mUniqueId = sId;
NestedTabChildMap()[sId] = aTabChild;
return sId;
}
NS_DECL_ISUPPORTS_INHERITED
@ -507,10 +519,7 @@ private:
*
* |aIsBrowserElement| indicates whether we're a browser (but not an app).
*/
TabChild(nsIContentChild* aManager,
const TabId& aTabId,
const TabContext& aContext,
uint32_t aChromeFlags);
TabChild(nsIContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags);
nsresult Init();
@ -558,14 +567,6 @@ private:
void SendPendingTouchPreventedResponse(bool aPreventDefault,
const ScrollableLayerGuid& aGuid);
void SetTabId(const TabId& aTabId)
{
MOZ_ASSERT(mUniqueId == 0);
mUniqueId = aTabId;
NestedTabChildMap()[mUniqueId] = this;
}
class CachedFileDescriptorInfo;
class CachedFileDescriptorCallbackRunnable;
@ -609,8 +610,8 @@ private:
bool mIgnoreKeyPressEvent;
nsRefPtr<ActiveElementManager> mActiveElementManager;
bool mHasValidInnerSize;
uint64_t mUniqueId;
bool mDestroyed;
TabId mUniqueId;
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
};

Просмотреть файл

@ -256,8 +256,8 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
const PopupIPCTabContext &ipcContext = appBrowser.get_PopupIPCTabContext();
TabContext *context;
if (ipcContext.opener().type() == PBrowserOrId::TPBrowserParent) {
context = static_cast<TabParent*>(ipcContext.opener().get_PBrowserParent());
if (ipcContext.openerParent()) {
context = static_cast<TabParent*>(ipcContext.openerParent());
if (context->IsBrowserElement() && !ipcContext.isBrowserElement()) {
// If the TabParent corresponds to a browser element, then it can only
// open other browser elements, for security reasons. We should have
@ -267,13 +267,8 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
"open a non-browser tab.";
return;
}
} else if (ipcContext.opener().type() == PBrowserOrId::TPBrowserChild) {
context = static_cast<TabChild*>(ipcContext.opener().get_PBrowserChild());
} else if (ipcContext.opener().type() == PBrowserOrId::TTabId) {
// We should never get here because this PopupIPCTabContext is only
// used for allocating a new tab id, not for allocating a PBrowser.
mInvalidReason = "Child process tried to open an tab without the opener information.";
return;
} else if (ipcContext.openerChild()) {
context = static_cast<TabChild*>(ipcContext.openerChild());
} else {
// This should be unreachable because PopupIPCTabContext::opener is not a
// nullable field.

Просмотреть файл

@ -218,10 +218,7 @@ NS_IMPL_ISUPPORTS(TabParent,
nsISecureBrowserUI,
nsISupportsWeakReference)
TabParent::TabParent(nsIContentParent* aManager,
const TabId& aTabId,
const TabContext& aContext,
uint32_t aChromeFlags)
TabParent::TabParent(nsIContentParent* aManager, const TabContext& aContext, uint32_t aChromeFlags)
: TabContext(aContext)
, mFrameElement(nullptr)
, mIMESelectionAnchor(0)
@ -245,7 +242,6 @@ TabParent::TabParent(nsIContentParent* aManager,
, mAppPackageFileDescriptorSent(false)
, mSendOfflineStatus(true)
, mChromeFlags(aChromeFlags)
, mTabId(aTabId)
{
MOZ_ASSERT(aManager);
}
@ -322,13 +318,7 @@ TabParent::Recv__delete__()
{
if (XRE_GetProcessType() == GeckoProcessType_Default) {
Manager()->AsContentParent()->NotifyTabDestroyed(this, mMarkedDestroying);
ContentParent::DeallocateTabId(mTabId,
Manager()->AsContentParent()->ChildID());
}
else {
ContentParent::DeallocateTabId(mTabId, ContentParentId(0));
}
return true;
}
@ -1660,16 +1650,6 @@ TabParent::GetFrom(nsIContent* aContent)
return GetFrom(frameLoader);
}
/*static*/ TabId
TabParent::GetTabIdFrom(nsIDocShell *docShell)
{
nsCOMPtr<nsITabChild> tabChild(TabChild::GetFrom(docShell));
if (tabChild) {
return static_cast<TabChild*>(tabChild.get())->GetTabId();
}
return TabId(0);
}
RenderFrameParent*
TabParent::GetRenderFrame()
{

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/dom/PBrowserParent.h"
#include "mozilla/dom/PFilePickerParent.h"
#include "mozilla/dom/TabContext.h"
#include "mozilla/dom/ipc/IdType.h"
#include "nsCOMPtr.h"
#include "nsIAuthPromptProvider.h"
#include "nsIBrowserDOMWindow.h"
@ -29,7 +28,6 @@ class nsIURI;
class nsIWidget;
class nsILoadContext;
class CpowHolder;
class nsIDocShell;
namespace mozilla {
@ -69,10 +67,7 @@ public:
// nsITabParent
NS_DECL_NSITABPARENT
TabParent(nsIContentParent* aManager,
const TabId& aTabId,
const TabContext& aContext,
uint32_t aChromeFlags);
TabParent(nsIContentParent* aManager, const TabContext& aContext, uint32_t aChromeFlags);
Element* GetOwnerElement() const { return mFrameElement; }
void SetOwnerElement(Element* aElement);
@ -329,7 +324,6 @@ public:
static TabParent* GetFrom(nsFrameLoader* aFrameLoader);
static TabParent* GetFrom(nsIContent* aContent);
static TabId GetTabIdFrom(nsIDocShell* docshell);
nsIContentParent* Manager() { return mManager; }
@ -341,11 +335,6 @@ public:
already_AddRefed<nsIWidget> GetWidget() const;
const TabId GetTabId() const
{
return mTabId;
}
protected:
bool ReceiveMessage(const nsString& aMessage,
bool aSync,
@ -452,8 +441,6 @@ private:
uint32_t mChromeFlags;
nsCOMPtr<nsILoadContext> mLoadContext;
TabId mTabId;
};
} // namespace dom

Просмотреть файл

@ -11,7 +11,6 @@ EXPORTS += [
EXPORTS.mozilla.dom.ipc += [
'BlobChild.h',
'BlobParent.h',
'IdType.h',
'nsIRemoteBlob.h',
]
@ -21,7 +20,6 @@ EXPORTS.mozilla.dom += [
'ContentChild.h',
'ContentParent.h',
'ContentProcess.h',
'ContentProcessManager.h',
'CPOWManagerGetter.h',
'CrashReporterChild.h',
'CrashReporterParent.h',
@ -49,7 +47,6 @@ UNIFIED_SOURCES += [
'ContentBridgeParent.cpp',
'ContentParent.cpp',
'ContentProcess.cpp',
'ContentProcessManager.cpp',
'CrashReporterParent.cpp',
'FilePickerParent.cpp',
'nsIContentChild.cpp',
@ -80,7 +77,6 @@ IPDL_SOURCES += [
'PBlob.ipdl',
'PBlobStream.ipdl',
'PBrowser.ipdl',
'PBrowserOrId.ipdlh',
'PColorPicker.ipdl',
'PContent.ipdl',
'PContentBridge.ipdl',

Просмотреть файл

@ -50,10 +50,9 @@ nsIContentChild::DeallocPJavaScriptChild(PJavaScriptChild* aChild)
}
PBrowserChild*
nsIContentChild::AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
nsIContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
@ -70,7 +69,7 @@ nsIContentChild::AllocPBrowserChild(const TabId& aTabId,
}
nsRefPtr<TabChild> child =
TabChild::Create(this, aTabId, tc.GetTabContext(), aChromeFlags);
TabChild::Create(this, tc.GetTabContext(), aChromeFlags);
// The ref here is released in DeallocPBrowserChild.
return child.forget().take();

Просмотреть файл

@ -7,8 +7,6 @@
#ifndef mozilla_dom_nsIContentChild_h
#define mozilla_dom_nsIContentChild_h
#include "mozilla/dom/ipc/IdType.h"
#include "nsISupports.h"
#include "nsTArrayForwardDeclare.h"
#include "mozilla/dom/CPOWManagerGetter.h"
@ -54,20 +52,18 @@ public:
virtual bool
SendPBrowserConstructor(PBrowserChild* aActor,
const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpID,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) = 0;
protected:
virtual jsipc::PJavaScriptChild* AllocPJavaScriptChild();
virtual bool DeallocPJavaScriptChild(jsipc::PJavaScriptChild*);
virtual PBrowserChild* AllocPBrowserChild(const TabId& aTabId,
const IPCTabContext& aContext,
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserChild(PBrowserChild*);

Просмотреть файл

@ -24,13 +24,6 @@
using namespace mozilla::jsipc;
// XXX need another bug to move this to a common header.
#ifdef DISABLE_ASSERTS_FOR_FUZZING
#define ASSERT_UNLESS_FUZZING(...) do { } while (0)
#else
#define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false, __VA_ARGS__)
#endif
namespace mozilla {
namespace dom {
@ -81,19 +74,14 @@ nsIContentParent::CanOpenBrowser(const IPCTabContext& aContext)
// (PopupIPCTabContext lets the child process prove that it has access to
// the app it's trying to open.)
if (appBrowser.type() != IPCTabAppBrowserContext::TPopupIPCTabContext) {
ASSERT_UNLESS_FUZZING("Unexpected IPCTabContext type. Aborting AllocPBrowserParent.");
NS_ERROR("Unexpected IPCTabContext type. Aborting AllocPBrowserParent.");
return false;
}
const PopupIPCTabContext& popupContext = appBrowser.get_PopupIPCTabContext();
if (popupContext.opener().type() != PBrowserOrId::TPBrowserParent) {
ASSERT_UNLESS_FUZZING("Unexpected PopupIPCTabContext type. Aborting AllocPBrowserParent.");
return false;
}
auto opener = static_cast<TabParent*>(popupContext.opener().get_PBrowserParent());
TabParent* opener = static_cast<TabParent*>(popupContext.openerParent());
if (!opener) {
ASSERT_UNLESS_FUZZING("Got null opener from child; aborting AllocPBrowserParent.");
NS_ERROR("Got null opener from child; aborting AllocPBrowserParent.");
return false;
}
@ -101,7 +89,7 @@ nsIContentParent::CanOpenBrowser(const IPCTabContext& aContext)
// isBrowser. Allocating a !isBrowser frame with same app ID would allow
// the content to access data it's not supposed to.
if (!popupContext.isBrowserElement() && opener->IsBrowserElement()) {
ASSERT_UNLESS_FUZZING("Child trying to escalate privileges! Aborting AllocPBrowserParent.");
NS_ERROR("Child trying to escalate privileges! Aborting AllocPBrowserParent.");
return false;
}
@ -117,14 +105,14 @@ nsIContentParent::CanOpenBrowser(const IPCTabContext& aContext)
}
PBrowserParent*
nsIContentParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
nsIContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
unused << aCpId;
unused << aChromeFlags;
unused << aId;
unused << aIsForApp;
unused << aIsForBrowser;
@ -134,7 +122,7 @@ nsIContentParent::AllocPBrowserParent(const TabId& aTabId,
MaybeInvalidTabContext tc(aContext);
MOZ_ASSERT(tc.IsValid());
TabParent* parent = new TabParent(this, aTabId, tc.GetTabContext(), aChromeFlags);
TabParent* parent = new TabParent(this, tc.GetTabContext(), aChromeFlags);
// We release this ref in DeallocPBrowserParent()
NS_ADDREF(parent);

Просмотреть файл

@ -7,8 +7,6 @@
#ifndef mozilla_dom_nsIContentParent_h
#define mozilla_dom_nsIContentParent_h
#include "mozilla/dom/ipc/IdType.h"
#include "nsFrameMessageManager.h"
#include "nsISupports.h"
#include "mozilla/dom/CPOWManagerGetter.h"
@ -51,7 +49,7 @@ public:
BlobParent* GetOrCreateActorForBlob(File* aBlob);
virtual ContentParentId ChildID() = 0;
virtual uint64_t ChildID() = 0;
virtual bool IsForApp() = 0;
virtual bool IsForBrowser() = 0;
@ -61,10 +59,9 @@ public:
virtual PBrowserParent* SendPBrowserConstructor(
PBrowserParent* actor,
const TabId& aTabId,
const IPCTabContext& context,
const uint32_t& chromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser) NS_WARN_UNUSED_RESULT = 0;
@ -78,10 +75,9 @@ protected: // IPDL methods
virtual mozilla::jsipc::PJavaScriptParent* AllocPJavaScriptParent();
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*);
virtual PBrowserParent* AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
virtual PBrowserParent* AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserParent(PBrowserParent* frame);

Просмотреть файл

@ -1041,8 +1041,7 @@ MobileConnection::NotifyDataError(const nsAString& aMessage)
}
NS_IMETHODIMP
MobileConnection::NotifyCFStateChanged(bool aSuccess,
unsigned short aAction,
MobileConnection::NotifyCFStateChanged(unsigned short aAction,
unsigned short aReason,
const nsAString& aNumber,
unsigned short aSeconds,
@ -1055,7 +1054,6 @@ MobileConnection::NotifyCFStateChanged(bool aSuccess,
CFStateChangeEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mSuccess = aSuccess;
init.mAction = aAction;
init.mReason = aReason;
init.mNumber = aNumber;

Просмотреть файл

@ -665,8 +665,8 @@ MobileConnectionProvider.prototype = {
notifyCFStateChanged: function(aAction, aReason, aNumber, aTimeSeconds,
aServiceClass) {
this.deliverListenerEvent("notifyCFStateChanged",
[true, aAction, aReason, aNumber, aTimeSeconds,
aServiceClass]);
[aAction, aReason, aNumber, aTimeSeconds,
aServiceClass]);
},
getSupportedNetworkTypes: function(aTypes) {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше