Merge latest green inbound changeset and mozilla-central

This commit is contained in:
Ed Morley 2013-07-23 13:56:12 +01:00
commit 3bcb2143f6
11 changed files with 315 additions and 185 deletions

View File

@ -1,4 +1,4 @@
{
"revision": "afc73def64af0d75874cc47ad3d02e16e645ffbc",
"revision": "d39f167ee1b770d2312a7b35bbcb29afe83b5c4f",
"repo_path": "/integration/gaia-central"
}

View File

@ -43,32 +43,32 @@ function testBreakOnAll()
is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
is(packet.frame.callee.name, "keyupHandler", "The keyupHandler is entered.");
gThreadClient.resume(function() {
gClient.addOneTimeListener("paused", function(event, packet) {
is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
is(packet.frame.callee.name, "clickHandler", "The clickHandler is entered.");
gClient.addOneTimeListener("paused", function(event, packet) {
is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
is(packet.frame.callee.name, "clickHandler", "The clickHandler is entered.");
is(packet.frame.callee.name, "onchange", "The onchange handler is entered.");
gThreadClient.resume(function() {
gClient.addOneTimeListener("paused", function(event, packet) {
is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
is(packet.frame.callee.name, "onchange", "The onchange handler is entered.");
gThreadClient.resume(testBreakOnDisabled);
});
gInput.focus();
gInput.value = "foo";
gInput.blur();
});
gThreadClient.resume(testBreakOnDisabled);
});
gThreadClient.resume(function() {
gInput.focus();
gInput.value = "foo";
gInput.blur();
});
});
gThreadClient.resume(function() {
EventUtils.sendMouseEvent({ type: "click" }, gButton);
});
});
gThreadClient.resume(function() {
gInput.focus();
EventUtils.synthesizeKey("e", {}, content);
EventUtils.synthesizeKey("e", { shiftKey: 1 }, content);
});
});
});
@ -95,7 +95,7 @@ function testBreakOnDisabled()
}, false);
gInput.focus();
EventUtils.synthesizeKey("e", {}, content);
EventUtils.synthesizeKey("e", { shiftKey: 1 }, content);
});
}
@ -118,7 +118,7 @@ function testBreakOnNone()
}, false);
gInput.focus();
EventUtils.synthesizeKey("g", {}, content);
EventUtils.synthesizeKey("g", { shiftKey: 1 }, content);
});
}

View File

@ -31,7 +31,7 @@ function testEventListeners()
gClient.addOneTimeListener("paused", function(aEvent, aPacket) {
is(aPacket.why.type, "debuggerStatement", "debugger statement was hit.");
gThreadClient.eventListeners(function(aPacket) {
is(aPacket.listeners.length, 4, "Found all event listeners.");
is(aPacket.listeners.length, 3, "Found all event listeners.");
let types = [];
for (let l of aPacket.listeners) {
let node = l.node;

View File

@ -8,12 +8,17 @@ const Cu = Components.utils;
let tempScope = {};
Cu.import("resource://gre/modules/Services.jsm", tempScope);
let Services = tempScope.Services;
// Disable logging for faster test runs. Set this pref to true if you want to
// debug a test in your try runs.
let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
Services.prefs.setBoolPref("devtools.debugger.log", false);
Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
Cu.import("resource://gre/modules/devtools/dbg-client.jsm", tempScope);
Cu.import("resource:///modules/source-editor.jsm", tempScope);
Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope);
let Services = tempScope.Services;
let SourceEditor = tempScope.SourceEditor;
let DebuggerServer = tempScope.DebuggerServer;
let DebuggerTransport = tempScope.DebuggerTransport;
@ -31,11 +36,9 @@ const TAB1_URL = EXAMPLE_URL + "browser_dbg_tab1.html";
const TAB2_URL = EXAMPLE_URL + "browser_dbg_tab2.html";
const STACK_URL = EXAMPLE_URL + "browser_dbg_stack.html";
// Enable logging and remote debugging for the relevant tests.
// Enable remote debugging for the relevant tests.
let gEnableRemote = Services.prefs.getBoolPref("devtools.debugger.remote-enabled");
let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
Services.prefs.setBoolPref("devtools.debugger.log", true);
// Redeclare dbg_assert with a fatal behavior.
function dbg_assert(cond, e) {

View File

@ -6,7 +6,8 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript">
window.addEventListener("load", function() {
window.addEventListener("load", function onload() {
window.removeEventListener("load", onload);
function initialSetup(event) {
debugger;
var button = document.querySelector("button");

View File

@ -51,6 +51,8 @@ const NETD_COMMAND_UNSOLICITED = 600;
const NETD_COMMAND_INTERFACE_CHANGE = 600;
const NETD_COMMAND_BANDWIDTH_CONTROLLER = 601;
const INTERFACE_DELIMIT = "\0";
importScripts("systemlibs.js");
function netdResponseType(code) {
@ -342,7 +344,8 @@ function onNetdMessage(data) {
}
if (gCurrentCallback) {
gCurrentCallback(isError(code), {code: code, reason: gReason.join(" ")});
gCurrentCallback(isError(code),
{code: code, reason: gReason.join(INTERFACE_DELIMIT)});
gReason = [];
}
@ -391,7 +394,7 @@ function setIpForwardingEnabled(params, callback) {
} else {
// Don't disable ip forwarding because others interface still need it.
// Send the dummy command to continue the function chain.
if (params.interfaceList.length > 1) {
if ("interfaceList" in params && params.interfaceList.length > 1) {
command = DUMMY_COMMAND;
} else {
command = "ipfwd disable";
@ -423,7 +426,7 @@ function stopTethering(params, callback) {
// Don't stop tethering because others interface still need it.
// Send the dummy to continue the function chain.
if (params.interfaceList.length > 1) {
if ("interfaceList" in params && params.interfaceList.length > 1) {
command = DUMMY_COMMAND;
} else {
command = "tether stop";
@ -442,7 +445,7 @@ function preTetherInterfaceList(params, callback) {
}
function postTetherInterfaceList(params, callback) {
params.interfaceList = params.resultReason.split(" ");
params.interfaceList = params.resultReason.split(INTERFACE_DELIMIT);
// Send the dummy command to continue the function chain.
let command = DUMMY_COMMAND;
@ -470,7 +473,7 @@ function disableNat(params, callback) {
// Don't disable nat because others interface still need it.
// Send the dummy command to continue the function chain.
if (params.interfaceList.length > 1) {
if ("interfaceList" in params && params.interfaceList.length > 1) {
command = DUMMY_COMMAND;
} else {
command = "nat disable " + params.internalIfname + " " +
@ -626,8 +629,10 @@ function dumpParams(params, type) {
debug(" ip: " + params.ip);
debug(" link: " + params.link);
debug(" prefix: " + params.prefix);
debug(" startIp: " + params.startIp);
debug(" endIp: " + params.endIp);
debug(" wifiStartIp: " + params.wifiStartIp);
debug(" wifiEndIp: " + params.wifiEndIp);
debug(" usbStartIp: " + params.usbStartIp);
debug(" usbEndIp: " + params.usbEndIp);
debug(" dnsserver1: " + params.dns1);
debug(" dnsserver2: " + params.dns2);
debug(" internalIfname: " + params.internalIfname);

View File

@ -994,7 +994,7 @@ let RIL = {
default:
options.errorMsg = "Unsupported Card Lock.";
options.success = false;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}
},
@ -1064,7 +1064,7 @@ let RIL = {
default:
options.errorMsg = "Unsupported Card Lock.";
options.success = false;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}
} else { // Enable/Disable lock.
switch (options.lockType) {
@ -1079,7 +1079,7 @@ let RIL = {
default:
options.errorMsg = "Unsupported Card Lock.";
options.success = false;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
options.enabled = options.enabled;
@ -1187,7 +1187,7 @@ let RIL = {
default:
options.errorMsg = "Unsupported Card Lock.";
options.success = false;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -1219,7 +1219,7 @@ let RIL = {
/* unknown lock type */
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
options.success = false;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -1231,7 +1231,7 @@ let RIL = {
/* ... while the phones do not. */
options.errorMsg = GECKO_ERROR_REQUEST_NOT_SUPPORTED;
options.success = false;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}
},
@ -1383,7 +1383,7 @@ let RIL = {
if (!this.appType) {
options.rilMessageType = "icccontacts";
options.errorMsg = GECKO_ERROR_REQUEST_NOT_SUPPORTED;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}
ICCContactHelper.readICCContacts(
@ -1393,12 +1393,12 @@ let RIL = {
// Reuse 'options' to get 'requestId' and 'contactType'.
options.rilMessageType = "icccontacts";
options.contacts = contacts;
RIL.sendDOMMessage(options);
RIL.sendChromeMessage(options);
}.bind(this),
function onerror(errorMsg) {
options.rilMessageType = "icccontacts";
options.errorMsg = errorMsg;
RIL.sendDOMMessage(options);
RIL.sendChromeMessage(options);
}.bind(this));
},
@ -1414,13 +1414,13 @@ let RIL = {
let onsuccess = function onsuccess() {
// Reuse 'options' to get 'requestId' and 'contactType'.
options.rilMessageType = "icccontactupdate";
RIL.sendDOMMessage(options);
RIL.sendChromeMessage(options);
}.bind(this);
let onerror = function onerror(errorMsg) {
options.rilMessageType = "icccontactupdate";
options.errorMsg = errorMsg;
RIL.sendDOMMessage(options);
RIL.sendChromeMessage(options);
}.bind(this);
if (!this.appType || !options.contact) {
@ -1736,7 +1736,7 @@ let RIL = {
options.callIndex = -1;
options.rilMessageType = "callError";
options.errorMsg = errorMsg;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}).bind(this);
if (this._isEmergencyNumber(options.number)) {
@ -1777,7 +1777,7 @@ let RIL = {
this.cachedDialRequest.callback = this.sendDialRequest.bind(this, options);
// Change radio setting value in settings DB to enable radio.
this.sendDOMMessage({rilMessageType: "setRadioEnabled", on: true});
this.sendChromeMessage({rilMessageType: "setRadioEnabled", on: true});
return;
}
@ -2012,7 +2012,7 @@ let RIL = {
debug("Invalid Cell Broadcast search list: " + e);
}
options.rilRequestError = ERROR_GENERIC_FAILURE;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -2159,7 +2159,7 @@ let RIL = {
Buf.sendParcel();
datacall.state = GECKO_NETWORK_STATE_DISCONNECTING;
this.sendDOMMessage(datacall);
this.sendChromeMessage(datacall);
},
/**
@ -2177,13 +2177,52 @@ let RIL = {
},
/**
* Helper to parse and process a MMI string.
* Helper to parse MMI/USSD string. TS.22.030 Figure 3.5.3.2.
*/
_parseMMI: function _parseMMI(mmiString) {
if (!mmiString || !mmiString.length) {
return null;
}
let matches = this._matchMMIRegexp(mmiString);
if (matches) {
// After successfully executing the regular expresion over the MMI string,
// the following match groups should contain:
// 1 = full MMI string that might be used as a USSD request.
// 2 = MMI procedure.
// 3 = Service code.
// 5 = SIA.
// 7 = SIB.
// 9 = SIC.
// 11 = Password registration.
// 12 = Dialing number.
return {
fullMMI: matches[MMI_MATCH_GROUP_FULL_MMI],
procedure: matches[MMI_MATCH_GROUP_MMI_PROCEDURE],
serviceCode: matches[MMI_MATCH_GROUP_SERVICE_CODE],
sia: matches[MMI_MATCH_GROUP_SIA],
sib: matches[MMI_MATCH_GROUP_SIB],
sic: matches[MMI_MATCH_GROUP_SIC],
pwd: matches[MMI_MATCH_GROUP_PWD_CONFIRM],
dialNumber: matches[MMI_MATCH_GROUP_DIALING_NUMBER]
};
}
if (this._isPoundString(mmiString) ||
this._isMMIShortString(mmiString)) {
return {
fullMMI: mmiString
};
}
return null;
},
/**
* Helper to parse MMI string via regular expression. TS.22.030 Figure
* 3.5.3.2.
*/
_matchMMIRegexp: function _matchMMIRegexp(mmiString) {
// Regexp to parse and process the MMI code.
if (this._mmiRegExp == null) {
// The first group of the regexp takes the whole MMI string.
@ -2226,41 +2265,41 @@ let RIL = {
this._mmiRegExp = new RegExp(pattern);
}
let matches = this._mmiRegExp.exec(mmiString);
// If the regex does not apply over the MMI string, it can still be an MMI
// code. If the MMI String is a #-string (entry of any characters defined
// in the TS.23.038 Default Alphabet followed by #SEND) it shall be treated
// as a USSD code.
if (matches == null) {
if (mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD) {
return {
fullMMI: mmiString
};
}
return null;
// Regex only applys for those well-defined MMI strings (refer to TS.22.030
// Annex B), otherwise, null should be the expected return value.
return this._mmiRegExp.exec(mmiString);
},
/**
* Helper to parse # string. TS.22.030 Figure 3.5.3.2.
*/
_isPoundString: function _isPoundString(mmiString) {
return (mmiString.charAt(mmiString.length - 1) === MMI_END_OF_USSD);
},
/**
* Helper to parse short string. TS.22.030 Figure 3.5.3.2.
*/
_isMMIShortString: function _isMMIShortString(mmiString) {
if (mmiString.length > 2) {
return false;
}
// After successfully executing the regular expresion over the MMI string,
// the following match groups should contain:
// 1 = full MMI string that might be used as a USSD request.
// 2 = MMI procedure.
// 3 = Service code.
// 5 = SIA.
// 7 = SIB.
// 9 = SIC.
// 11 = Password registration.
// 12 = Dialing number.
return {
fullMMI: matches[MMI_MATCH_GROUP_FULL_MMI],
procedure: matches[MMI_MATCH_GROUP_MMI_PROCEDURE],
serviceCode: matches[MMI_MATCH_GROUP_SERVICE_CODE],
sia: matches[MMI_MATCH_GROUP_SIA],
sib: matches[MMI_MATCH_GROUP_SIB],
sic: matches[MMI_MATCH_GROUP_SIC],
pwd: matches[MMI_MATCH_GROUP_PWD_CONFIRM],
dialNumber: matches[MMI_MATCH_GROUP_DIALING_NUMBER]
};
if (this._isEmergencyNumber(mmiString)) {
return false;
}
// In a call case.
if (Object.getOwnPropertyNames(this.currentCalls).length > 0) {
return true;
}
if ((mmiString.length != 2) || (mmiString.charAt(0) !== '1')) {
return true;
}
return false;
},
sendMMI: function sendMMI(options) {
@ -2277,7 +2316,7 @@ let RIL = {
if (mmiServiceCode) {
options.mmiServiceCode = mmiServiceCode;
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}).bind(this);
function _isValidPINPUKRequest(mmiServiceCode) {
@ -2447,11 +2486,11 @@ let RIL = {
this.getIMEI({mmi: true});
return;
}
// If we already had the device's IMEI, we just send it to the DOM.
// If we already had the device's IMEI, we just send it to chrome.
options.mmiServiceCode = MMI_KS_SC_IMEI;
options.success = true;
options.statusMessage = this.IMEI;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
// CLIP
@ -2501,10 +2540,9 @@ let RIL = {
return;
}
// If the MMI code is not a known code and is a recognized USSD request or
// a #-string, it shall still be sent as a USSD request.
if (mmi.fullMMI &&
(mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD)) {
// If the MMI code is not a known code and is a recognized USSD request,
// it shall still be sent as a USSD request.
if (mmi.fullMMI) {
if (!_isRadioAvailable(MMI_KS_SC_USSD)) {
return;
}
@ -3096,8 +3134,8 @@ let RIL = {
return;
}
this.cardState = newCardState;
this.sendDOMMessage({rilMessageType: "cardstatechange",
cardState: this.cardState});
this.sendChromeMessage({rilMessageType: "cardstatechange",
cardState: this.cardState});
return;
}
@ -3111,8 +3149,8 @@ let RIL = {
}
this.operator = null;
this.cardState = GECKO_CARDSTATE_UNKNOWN;
this.sendDOMMessage({rilMessageType: "cardstatechange",
cardState: this.cardState});
this.sendChromeMessage({rilMessageType: "cardstatechange",
cardState: this.cardState});
return;
}
// fetchICCRecords will need to read aid, so read aid here.
@ -3163,8 +3201,8 @@ let RIL = {
}
this.cardState = newCardState;
this.sendDOMMessage({rilMessageType: "cardstatechange",
cardState: this.cardState});
this.sendChromeMessage({rilMessageType: "cardstatechange",
cardState: this.cardState});
},
/**
@ -3178,7 +3216,7 @@ let RIL = {
}
options.retryCount = length ? Buf.readUint32List()[0] : -1;
if (options.rilMessageType != "sendMMI") {
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -3220,7 +3258,7 @@ let RIL = {
}
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
},
// We combine all of the NETWORK_INFO_MESSAGE_TYPES into one "networkinfochange"
@ -3246,7 +3284,7 @@ let RIL = {
if (!this._processingNetworkInfo) {
// We only combine these messages in the case of the combined request
// in requestNetworkInfo()
this.sendDOMMessage(message);
this.sendChromeMessage(message);
return;
}
@ -3294,7 +3332,7 @@ let RIL = {
},
_sendPendingNetworkInfo: function _sendPendingNetworkInfo() {
RIL.sendDOMMessage(RIL._pendingNetworkInfo);
RIL.sendChromeMessage(RIL._pendingNetworkInfo);
RIL._processingNetworkInfo = false;
for (let i = 0; i < NETWORK_INFO_MESSAGE_TYPES.length; i++) {
@ -3500,7 +3538,7 @@ let RIL = {
// State has changed.
if (newCall.state == CALL_STATE_INCOMING &&
currentCall.state == CALL_STATE_WAITING) {
// Update the call internally but we don't notify DOM since these two
// Update the call internally but we don't notify chrome since these two
// states are viewed as the same one there.
currentCall.state = newCall.state;
continue;
@ -3550,13 +3588,13 @@ let RIL = {
_handleChangedCallState: function _handleChangedCallState(changedCall) {
let message = {rilMessageType: "callStateChange",
call: changedCall};
this.sendDOMMessage(message);
this.sendChromeMessage(message);
},
_handleDisconnectedCall: function _handleDisconnectedCall(disconnectedCall) {
let message = {rilMessageType: "callDisconnected",
call: disconnectedCall};
this.sendDOMMessage(message);
this.sendChromeMessage(message);
},
_sendDataCallError: function _sendDataCallError(message, errorCode) {
@ -3566,7 +3604,7 @@ let RIL = {
} else {
message.errorMsg = RIL_DATACALL_FAILCAUSE_TO_GECKO_DATACALL_ERROR[errorCode];
}
this.sendDOMMessage(message);
this.sendChromeMessage(message);
},
_processDataCallList: function _processDataCallList(datacalls, newDataCallOptions) {
@ -3594,7 +3632,7 @@ let RIL = {
if (!newDataCallOptions) {
currentDataCall.state = GECKO_NETWORK_STATE_DISCONNECTED;
currentDataCall.rilMessageType = "datacallstatechange";
this.sendDOMMessage(currentDataCall);
this.sendChromeMessage(currentDataCall);
}
continue;
}
@ -3603,7 +3641,7 @@ let RIL = {
delete this.currentDataCalls[currentDataCall.cid];
currentDataCall.state = GECKO_NETWORK_STATE_UNKNOWN;
currentDataCall.rilMessageType = "datacallstatechange";
this.sendDOMMessage(currentDataCall);
this.sendChromeMessage(currentDataCall);
continue;
}
@ -3613,7 +3651,7 @@ let RIL = {
currentDataCall.active = updatedDataCall.active;
currentDataCall.state = updatedDataCall.state;
currentDataCall.rilMessageType = "datacallstatechange";
this.sendDOMMessage(currentDataCall);
this.sendChromeMessage(currentDataCall);
}
}
@ -3635,7 +3673,7 @@ let RIL = {
debug("Unexpected new data call: " + JSON.stringify(newDataCall));
}
newDataCall.rilMessageType = "datacallstatechange";
this.sendDOMMessage(newDataCall);
this.sendChromeMessage(newDataCall);
}
},
@ -3981,7 +4019,7 @@ let RIL = {
message.result = PDU_FCS_RESERVED;
}
message.rilMessageType = "sms-received";
this.sendDOMMessage(message);
this.sendChromeMessage(message);
// We will acknowledge receipt of the SMS after we try to store it
// in the database.
@ -4040,7 +4078,7 @@ let RIL = {
let deliveryStatus = ((status >>> 5) === 0x00)
? GECKO_SMS_DELIVERY_STATUS_SUCCESS
: GECKO_SMS_DELIVERY_STATUS_ERROR;
this.sendDOMMessage({
this.sendChromeMessage({
rilMessageType: "sms-delivery",
envelopeId: options.envelopeId,
deliveryStatus: deliveryStatus
@ -4157,7 +4195,7 @@ let RIL = {
// Fallback to default error handling if it meets max retry count.
// Fall through.
default:
this.sendDOMMessage({
this.sendChromeMessage({
rilMessageType: "sms-send-failed",
envelopeId: options.envelopeId,
errorMsg: options.rilRequestError,
@ -4182,7 +4220,7 @@ let RIL = {
this._pendingSentSmsMap[options.messageRef] = options;
}
this.sendDOMMessage({
this.sendChromeMessage({
rilMessageType: "sms-sent",
envelopeId: options.envelopeId,
});
@ -4472,8 +4510,8 @@ let RIL = {
* @param message
* Object containing the message. Messages are supposed
*/
handleDOMMessage: function handleMessage(message) {
if (DEBUG) debug("Received DOM message " + JSON.stringify(message));
handleChromeMessage: function handleChromeMessage(message) {
if (DEBUG) debug("Received chrome message " + JSON.stringify(message));
let method = this[message.rilMessageType];
if (typeof method != "function") {
if (DEBUG) {
@ -4494,7 +4532,7 @@ let RIL = {
calls.push(call);
}
options.calls = calls;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
},
/**
@ -4505,8 +4543,8 @@ let RIL = {
for each (let datacall in this.currentDataCalls) {
datacall_list.push(datacall);
}
this.sendDOMMessage({rilMessageType: "datacalllist",
datacalls: datacall_list});
this.sendChromeMessage({rilMessageType: "datacalllist",
datacalls: datacall_list});
},
/**
@ -4533,7 +4571,7 @@ let RIL = {
" commandQualifier = " + cmdDetails.commandQualifier);
}
// STK_CMD_MORE_TIME need not to propagate event to DOM.
// STK_CMD_MORE_TIME need not to propagate event to chrome.
if (cmdDetails.typeOfCommand == STK_CMD_MORE_TIME) {
RIL.sendStkTerminalResponse({
command: cmdDetails,
@ -4543,13 +4581,13 @@ let RIL = {
cmdDetails.rilMessageType = "stkcommand";
cmdDetails.options = StkCommandParamsFactory.createParam(cmdDetails, ctlvs);
RIL.sendDOMMessage(cmdDetails);
RIL.sendChromeMessage(cmdDetails);
},
/**
* Send messages to the main thread.
*/
sendDOMMessage: function sendDOMMessage(message) {
sendChromeMessage: function sendChromeMessage(message) {
postMessage(message);
},
@ -4716,7 +4754,7 @@ RIL[REQUEST_GET_IMSI] = function REQUEST_GET_IMSI(length, options) {
options.rilMessageType = "iccimsi";
options.imsi = this.iccInfoPrivate.imsi;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
if (this._isCdma) {
let mccMnc = ICCUtilsHelper.parseMccMncFromImsi(this.iccInfoPrivate.imsi);
@ -4787,7 +4825,7 @@ RIL[REQUEST_LAST_CALL_FAIL_CAUSE] = function REQUEST_LAST_CALL_FAIL_CAUSE(length
default:
options.rilMessageType = "callError";
options.errorMsg = RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[failCause];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
break;
}
};
@ -4852,7 +4890,7 @@ RIL[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH(length, options)
if (DEBUG) debug("Signal strength " + JSON.stringify(obj));
obj.rilMessageType = "signalstrengthchange";
this.sendDOMMessage(obj);
this.sendChromeMessage(obj);
if (this.cachedDialRequest && obj.gsmDBM && obj.gsmRelative) {
// Radio is ready for making the cached emergency call.
@ -4941,7 +4979,7 @@ RIL[REQUEST_SETUP_DATA_CALL] = function REQUEST_SETUP_DATA_CALL(length, options)
this.readSetupDataCall_v5(options);
this.currentDataCalls[options.cid] = options;
options.rilMessageType = "datacallstatechange";
this.sendDOMMessage(options);
this.sendChromeMessage(options);
// Let's get the list of data calls to ensure we know whether it's active
// or not.
this.getDataCallList();
@ -4973,7 +5011,7 @@ RIL[REQUEST_SEND_USSD] = function REQUEST_SEND_USSD(length, options) {
}
options.success = (this._ussdSession = options.rilRequestError === 0);
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_CANCEL_USSD] = function REQUEST_CANCEL_USSD(length, options) {
if (DEBUG) {
@ -4982,13 +5020,13 @@ RIL[REQUEST_CANCEL_USSD] = function REQUEST_CANCEL_USSD(length, options) {
options.success = (options.rilRequestError === 0);
this._ussdSession = !options.success;
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_GET_CLIR] = function REQUEST_GET_CLIR(length, options) {
options.success = (options.rilRequestError === 0);
if (!options.success) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -4996,7 +5034,7 @@ RIL[REQUEST_GET_CLIR] = function REQUEST_GET_CLIR(length, options) {
if (!bufLength || bufLength < 2) {
options.success = false;
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -5066,7 +5104,7 @@ RIL[REQUEST_GET_CLIR] = function REQUEST_GET_CLIR(length, options) {
}
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SET_CLIR] = function REQUEST_SET_CLIR(length, options) {
options.success = (options.rilRequestError === 0);
@ -5083,7 +5121,7 @@ RIL[REQUEST_SET_CLIR] = function REQUEST_SET_CLIR(length, options) {
break;
}
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] =
@ -5091,7 +5129,7 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] =
options.success = (options.rilRequestError === 0);
if (!options.success) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -5102,7 +5140,7 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] =
if (!rulesLength) {
options.success = false;
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
let rules = new Array(rulesLength);
@ -5124,7 +5162,7 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] =
// instances.
options.additionalInformation = rules;
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SET_CALL_FORWARD] =
function REQUEST_SET_CALL_FORWARD(length, options) {
@ -5148,20 +5186,20 @@ RIL[REQUEST_SET_CALL_FORWARD] =
break;
}
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_QUERY_CALL_WAITING] =
function REQUEST_QUERY_CALL_WAITING(length, options) {
options.success = (options.rilRequestError === 0);
if (!options.success) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
options.length = Buf.readUint32();
options.enabled = ((Buf.readUint32() == 1) &&
((Buf.readUint32() & ICC_SERVICE_CLASS_VOICE) == 0x01));
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SET_CALL_WAITING] = function REQUEST_SET_CALL_WAITING(length, options) {
@ -5169,12 +5207,12 @@ RIL[REQUEST_SET_CALL_WAITING] = function REQUEST_SET_CALL_WAITING(length, option
if (!options.success) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SMS_ACKNOWLEDGE] = null;
RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) {
this.IMEI = Buf.readString();
// So far we only send the IMEI back to the DOM if it was requested via MMI.
// So far we only send the IMEI back to chrome if it was requested via MMI.
if (!options.mmi) {
return;
}
@ -5187,7 +5225,7 @@ RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) {
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
}
options.statusMessage = this.IMEI;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_GET_IMEISV] = function REQUEST_GET_IMEISV(length, options) {
if (options.rilRequestError) {
@ -5206,7 +5244,7 @@ RIL[REQUEST_DEACTIVATE_DATA_CALL] = function REQUEST_DEACTIVATE_DATA_CALL(length
delete this.currentDataCalls[options.cid];
datacall.state = GECKO_NETWORK_STATE_UNKNOWN;
datacall.rilMessageType = "datacallstatechange";
this.sendDOMMessage(datacall);
this.sendChromeMessage(datacall);
};
RIL[REQUEST_QUERY_FACILITY_LOCK] = function REQUEST_QUERY_FACILITY_LOCK(length, options) {
options.success = (options.rilRequestError === 0);
@ -5217,7 +5255,7 @@ RIL[REQUEST_QUERY_FACILITY_LOCK] = function REQUEST_QUERY_FACILITY_LOCK(length,
if (length) {
options.enabled = Buf.readUint32List()[0] === 0 ? false : true;
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SET_FACILITY_LOCK] = function REQUEST_SET_FACILITY_LOCK(length, options) {
options.success = (options.rilRequestError === 0);
@ -5225,34 +5263,34 @@ RIL[REQUEST_SET_FACILITY_LOCK] = function REQUEST_SET_FACILITY_LOCK(length, opti
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
}
options.retryCount = length ? Buf.readUint32List()[0] : -1;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_CHANGE_BARRING_PASSWORD] = null;
RIL[REQUEST_SIM_OPEN_CHANNEL] = function REQUEST_SIM_OPEN_CHANNEL(length, options) {
if (options.rilRequestError) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
options.channel = Buf.readUint32();
if (DEBUG) debug("Setting channel number in options: " + options.channel);
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SIM_CLOSE_CHANNEL] = function REQUEST_SIM_CLOSE_CHANNEL(length, options) {
if (options.rilRequestError) {
options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
// No return value
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SIM_ACCESS_CHANNEL] = function REQUEST_SIM_ACCESS_CHANNEL(length, options) {
if (options.rilRequestError) {
options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
}
options.sw1 = Buf.readUint32();
@ -5262,14 +5300,14 @@ RIL[REQUEST_SIM_ACCESS_CHANNEL] = function REQUEST_SIM_ACCESS_CHANNEL(length, op
debug("Setting return values for RIL[REQUEST_SIM_ACCESS_CHANNEL]: ["
+ options.sw1 + "," + options.sw2 + ", " + options.simResponse + "]");
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE(length, options) {
this._receivedNetworkInfo(NETWORK_INFO_NETWORK_SELECTION_MODE);
if (options.rilRequestError) {
options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -5297,30 +5335,30 @@ RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELEC
RIL[REQUEST_SET_NETWORK_SELECTION_AUTOMATIC] = function REQUEST_SET_NETWORK_SELECTION_AUTOMATIC(length, options) {
if (options.rilRequestError) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_SET_NETWORK_SELECTION_MANUAL] = function REQUEST_SET_NETWORK_SELECTION_MANUAL(length, options) {
if (options.rilRequestError) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_QUERY_AVAILABLE_NETWORKS] = function REQUEST_QUERY_AVAILABLE_NETWORKS(length, options) {
if (options.rilRequestError) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
options.networks = this._processNetworks();
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_DTMF_START] = null;
RIL[REQUEST_DTMF_STOP] = null;
@ -5339,7 +5377,7 @@ RIL[REQUEST_QUERY_CLIP] = function REQUEST_QUERY_CLIP(length, options) {
options.success = (options.rilRequestError === 0);
if (!options.success) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -5347,7 +5385,7 @@ RIL[REQUEST_QUERY_CLIP] = function REQUEST_QUERY_CLIP(length, options) {
if (!bufLength) {
options.success = false;
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
return;
}
@ -5371,7 +5409,7 @@ RIL[REQUEST_QUERY_CLIP] = function REQUEST_QUERY_CLIP(length, options) {
break;
}
}
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[REQUEST_LAST_DATA_CALL_FAIL_CAUSE] = null;
@ -5487,7 +5525,7 @@ RIL[REQUEST_SET_PREFERRED_NETWORK_TYPE] = function REQUEST_SET_PREFERRED_NETWORK
return;
}
this.sendDOMMessage({
this.sendChromeMessage({
rilMessageType: "setPreferredNetworkType",
networkType: options.networkType,
success: options.rilRequestError == ERROR_SUCCESS
@ -5503,7 +5541,7 @@ RIL[REQUEST_GET_PREFERRED_NETWORK_TYPE] = function REQUEST_GET_PREFERRED_NETWORK
}
}
this.sendDOMMessage({
this.sendChromeMessage({
rilMessageType: "getPreferredNetworkType",
networkType: networkType,
success: options.rilRequestError == ERROR_SUCCESS
@ -5605,7 +5643,7 @@ RIL[REQUEST_GET_UNLOCK_RETRY_COUNT] = function REQUEST_GET_UNLOCK_RETRY_COUNT(le
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
}
options.retryCount = length ? Buf.readUint32List()[0] : -1;
this.sendDOMMessage(options);
this.sendChromeMessage(options);
};
RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED() {
let radioState = Buf.readUint32();
@ -5676,7 +5714,7 @@ RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RA
}
this.radioState = newState;
this.sendDOMMessage({
this.sendChromeMessage({
rilMessageType: "radiostatechange",
radioState: newState
});
@ -5729,9 +5767,9 @@ RIL[UNSOLICITED_ON_USSD] = function UNSOLICITED_ON_USSD() {
this._ussdSession = (typeCode != "0" && typeCode != "2");
this.sendDOMMessage({rilMessageType: "USSDReceived",
message: message,
sessionEnded: !this._ussdSession});
this.sendChromeMessage({rilMessageType: "USSDReceived",
message: message,
sessionEnded: !this._ussdSession});
};
RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = function UNSOLICITED_NITZ_TIME_RECEIVED() {
let dateString = Buf.readString();
@ -5767,11 +5805,11 @@ RIL[UNSOLICITED_NITZ_TIME_RECEIVED] = function UNSOLICITED_NITZ_TIME_RECEIVED()
return;
}
this.sendDOMMessage({rilMessageType: "nitzTime",
networkTimeInMS: timeInMS,
networkTimeZoneInMinutes: -(tz * 15),
networkDSTInMinutes: -(dst * 60),
receiveTimeInMS: now});
this.sendChromeMessage({rilMessageType: "nitzTime",
networkTimeInMS: timeInMS,
networkTimeZoneInMinutes: -(tz * 15),
networkDSTInMinutes: -(dst * 60),
receiveTimeInMS: now});
};
RIL[UNSOLICITED_SIGNAL_STRENGTH] = function UNSOLICITED_SIGNAL_STRENGTH(length) {
@ -5787,7 +5825,7 @@ RIL[UNSOLICITED_DATA_CALL_LIST_CHANGED] = function UNSOLICITED_DATA_CALL_LIST_CH
RIL[UNSOLICITED_SUPP_SVC_NOTIFICATION] = null;
RIL[UNSOLICITED_STK_SESSION_END] = function UNSOLICITED_STK_SESSION_END() {
this.sendDOMMessage({rilMessageType: "stksessionend"});
this.sendChromeMessage({rilMessageType: "stksessionend"});
};
RIL[UNSOLICITED_STK_PROACTIVE_COMMAND] = function UNSOLICITED_STK_PROACTIVE_COMMAND() {
this.processStkProactiveCommand();
@ -5811,7 +5849,7 @@ RIL[UNSOLICITED_CALL_RING] = function UNSOLICITED_CALL_RING() {
// call, but that's enough to bring up the Phone app already. We'll know
// details once we get a call state changed notification and can then
// dispatch DOM events etc.
this.sendDOMMessage(info);
this.sendChromeMessage(info);
};
RIL[UNSOLICITED_RESPONSE_SIM_STATUS_CHANGED] = function UNSOLICITED_RESPONSE_SIM_STATUS_CHANGED() {
this.getICCStatus();
@ -5847,7 +5885,7 @@ RIL[UNSOLICITED_RESPONSE_NEW_BROADCAST_SMS] = function UNSOLICITED_RESPONSE_NEW_
}
message.rilMessageType = "cellbroadcast-received";
this.sendDOMMessage(message);
this.sendChromeMessage(message);
};
RIL[UNSOLICITED_CDMA_RUIM_SMS_STORAGE_FULL] = null;
RIL[UNSOLICITED_RESTRICTED_STATE_CHANGED] = null;
@ -10785,7 +10823,7 @@ let ICCRecordHelper = {
debug("MBDN, alphaId="+contact.alphaId+" number="+contact.number);
}
contact.rilMessageType = "iccmbdn";
RIL.sendDOMMessage(contact);
RIL.sendChromeMessage(contact);
}
ICCIOHelper.loadLinearFixedEF({fileId: ICC_EF_MBDN,
@ -11766,7 +11804,7 @@ let ICCUtilsHelper = {
*/
handleICCInfoChange: function handleICCInfoChange() {
RIL.iccInfo.rilMessageType = "iccinfochange";
RIL.sendDOMMessage(RIL.iccInfo);
RIL.sendChromeMessage(RIL.iccInfo);
},
/**
@ -12577,7 +12615,7 @@ function onRILMessage(data) {
}
onmessage = function onmessage(event) {
RIL.handleDOMMessage(event.data);
RIL.handleChromeMessage(event.data);
};
onerror = function onerror(event) {

View File

@ -70,14 +70,44 @@ add_test(function test_parseMMI_undefined() {
run_next_test();
});
add_test(function test_parseMMI_invalid() {
let mmi = parseMMI("**");
add_test(function test_parseMMI_one_digit_short_code() {
let mmi = parseMMI("1");
do_check_eq(mmi.fullMMI, "1");
do_check_eq(mmi.procedure, undefined);
do_check_eq(mmi.serviceCode, undefined);
do_check_eq(mmi.sia, undefined);
do_check_eq(mmi.sib, undefined);
do_check_eq(mmi.sic, undefined);
do_check_eq(mmi.pwd, undefined);
do_check_eq(mmi.dialNumber, undefined);
run_next_test();
});
add_test(function test_parseMMI_invalid_short_code() {
let mmi = parseMMI("11");
do_check_null(mmi);
run_next_test();
});
add_test(function test_parseMMI_short_code() {
let mmi = parseMMI("21");
do_check_eq(mmi.fullMMI, "21");
do_check_eq(mmi.procedure, undefined);
do_check_eq(mmi.serviceCode, undefined);
do_check_eq(mmi.sia, undefined);
do_check_eq(mmi.sib, undefined);
do_check_eq(mmi.sic, undefined);
do_check_eq(mmi.pwd, undefined);
do_check_eq(mmi.dialNumber, undefined);
run_next_test();
});
add_test(function test_parseMMI_dial_string() {
let mmi = parseMMI("12345");
@ -86,6 +116,21 @@ add_test(function test_parseMMI_dial_string() {
run_next_test();
});
add_test(function test_parseMMI_USSD_without_asterisk_prefix() {
let mmi = parseMMI("123#");
do_check_eq(mmi.fullMMI, "123#");
do_check_eq(mmi.procedure, undefined);
do_check_eq(mmi.serviceCode, undefined);
do_check_eq(mmi.sia, undefined);
do_check_eq(mmi.sib, undefined);
do_check_eq(mmi.sic, undefined);
do_check_eq(mmi.pwd, undefined);
do_check_eq(mmi.dialNumber, undefined);
run_next_test();
});
add_test(function test_parseMMI_USSD() {
let mmi = parseMMI("*123#");
@ -318,7 +363,33 @@ add_test(function test_sendMMI_undefined() {
});
add_test(function test_sendMMI_invalid() {
testSendMMI("**", MMI_ERROR_KS_ERROR);
testSendMMI("11", MMI_ERROR_KS_ERROR);
run_next_test();
});
add_test(function test_sendMMI_short_code() {
let workerhelper = getWorker();
let worker = workerhelper.worker;
let ussdOptions;
worker.RIL.sendUSSD = function fakeSendUSSD(options){
ussdOptions = options;
worker.RIL[REQUEST_SEND_USSD](0, {
rilRequestError: ERROR_SUCCESS
});
}
worker.RIL.radioState = GECKO_RADIOSTATE_READY;
worker.RIL.sendMMI({mmi: "**"});
let postedMessage = workerhelper.postedMessage;
do_check_eq(ussdOptions.ussd, "**");
do_check_eq (postedMessage.errorMsg, GECKO_ERROR_SUCCESS);
do_check_true(postedMessage.success);
do_check_true(worker.RIL._ussdSession);
run_next_test();
});

View File

@ -3205,6 +3205,7 @@ WifiWorker.prototype = {
// hotspot status. Toggle settings to let gaia know that wifi hotspot
// is enabled.
this.tetheringSettings[SETTINGS_WIFI_TETHERING_ENABLED] = true;
this._oldWifiTetheringEnabledState = true;
gSettingsService.createLock().set(
SETTINGS_WIFI_TETHERING_ENABLED, true, null, "fromInternalSetting");
// Check for the next request.
@ -3216,6 +3217,7 @@ WifiWorker.prototype = {
// hotspot status. Toggle settings to let gaia know that wifi hotspot
// is disabled.
this.tetheringSettings[SETTINGS_WIFI_TETHERING_ENABLED] = false;
this._oldWifiTetheringEnabledState = false;
gSettingsService.createLock().set(
SETTINGS_WIFI_TETHERING_ENABLED, false, null, "fromInternalSetting");
// Check for the next request.
@ -3333,6 +3335,7 @@ WifiWorker.prototype = {
break;
}
this._oldWifiTetheringEnabledState = this.tetheringSettings[SETTINGS_WIFI_TETHERING_ENABLED];
this.handleWifiTetheringEnabled(aResult)
break;
};

View File

@ -22,7 +22,7 @@ struct DBusConnection;
namespace mozilla {
namespace ipc {
class RawDBusConnection : public detail::RefCounted<RawDBusConnection, detail::AtomicRefCount>
class RawDBusConnection : public AtomicRefCounted<RawDBusConnection>
{
struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits<DBusConnection>
{

View File

@ -39,6 +39,15 @@
* (like querySelector) will include the extra nodes needed to satisfy this
* requirement. The client keeps track of this parent relationship, so the
* node fronts form a tree that is a subset of the actual DOM tree.
*
*
* We maintain this guarantee to support the ability to release subtrees on
* the client - when a node is disconnected from the DOM tree we want to be
* able to free the client objects for all the children nodes.
*
* So to be able to answer "all the children of a given node that we have
* seen on the client side", we guarantee that every time we've seen a node,
* we connect it up through its parents.
*/
const {Cc, Ci, Cu} = require("chrome");
@ -505,7 +514,7 @@ types.addDictType("disconnectedNode", {
node: "domnode",
// Nodes that are needed to connect the node to a node the client has already seen
newNodes: "array:domnode"
newParents: "array:domnode"
});
types.addDictType("disconnectedNodeArray", {
@ -513,7 +522,7 @@ types.addDictType("disconnectedNodeArray", {
nodes: "array:domnode",
// Nodes that are needed to connect those nodes to the root.
newNodes: "array:domnode"
newParents: "array:domnode"
});
types.addDictType("dommutation", {});
@ -562,10 +571,10 @@ var NodeListActor = exports.NodeListActor = protocol.ActorClass({
*/
item: method(function(index) {
let node = this.walker._ref(this.nodeList[index]);
let newNodes = [node for (node of this.walker.ensurePathToRoot(node))];
let newParents = [node for (node of this.walker.ensurePathToRoot(node))];
return {
node: node,
newNodes: newNodes
newParents: newParents
}
}, {
request: { item: Arg(0) },
@ -577,20 +586,20 @@ var NodeListActor = exports.NodeListActor = protocol.ActorClass({
*/
items: method(function(start=0, end=this.nodeList.length) {
let items = [this.walker._ref(item) for (item of Array.prototype.slice.call(this.nodeList, start, end))];
let newNodes = new Set();
let newParents = new Set();
for (let item of items) {
this.walker.ensurePathToRoot(item, newNodes);
this.walker.ensurePathToRoot(item, newParents);
}
return {
nodes: items,
newNodes: [node for (node of newNodes)]
newParents: [node for (node of newParents)]
}
}, {
request: {
start: Arg(0, "number", { optional: true }),
end: Arg(1, "number", { optional: true })
},
response: { nodes: RetVal("disconnectedNodeArray") }
response: RetVal("disconnectedNodeArray")
}),
release: method(function() {}, { release: true })
@ -1199,7 +1208,7 @@ var WalkerActor = protocol.ActorClass({
let newParents = this.ensurePathToRoot(node);
return {
node: node,
newNodes: [parent for (parent of newParents)]
newParents: [parent for (parent of newParents)]
}
}, {
request: {