diff options
author | msramek <msramek@chromium.org> | 2015-08-17 02:23:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-17 09:24:02 +0000 |
commit | 7f0dc75b563b74eeb4fa7f52edfae9650625a149 (patch) | |
tree | fd4baeccd8479176c088a1a251ff2c555f1e7500 /remoting | |
parent | c736b6bd3d9d49e43d09654a779913d048d3619d (diff) | |
download | chromium_src-7f0dc75b563b74eeb4fa7f52edfae9650625a149.zip chromium_src-7f0dc75b563b74eeb4fa7f52edfae9650625a149.tar.gz chromium_src-7f0dc75b563b74eeb4fa7f52edfae9650625a149.tar.bz2 |
Revert of Record the XMPP error in remoting.FormatIq. (patchset #4 id:60001 of )
Reason for revert:
Win x64 GN bot failure.
FAILED: E:/b/depot_tools/python276_bin/python.exe gyp-win-tool action-wrapper environment.x86 __remoting_webapp_build_unittest___build_toolchain_win_x64__rule.rsp
The command line is too long.
Original issue's description:
> Record the XMPP error in remoting.FormatIq.
>
> This CL
> 1. Records the XMPP error type, jingle_action and error condition
> in remoting.FormatIq.
> This error is later extracted by the ClientSession to upload along
> with session state change events.
>
> We choose to record the error in the webapp instead of the plugin to
> avoid adding new contract between the webapp and the plugin just for
> the sake of debugging, especially when we are so close to branch point.
> 2. Removes some legacy fields in the FormatIq to avoid parse errors.
> 3. Parses the error before the original jingle message. This ensures
> addition of unrecognized Jingle fields like QUIC will not break the
> error parsing.
>
> BUG=509070
>
> Committed: dba42ad74eb89a6663304462e6538ba568
> Cr-Commit-Position: refs/heads/master@{#343532}
TBR=jamiewalch@chromium.org,sergeyu@chromium.org,kelvinp@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=509070,521522
Review URL: https://codereview.chromium.org/1293103002
Cr-Commit-Position: refs/heads/master@{#343652}
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/remoting_webapp_files.gypi | 1 | ||||
-rw-r--r-- | remoting/webapp/base/js/chromoting_event.js | 42 | ||||
-rw-r--r-- | remoting/webapp/base/js/format_iq.js | 127 | ||||
-rw-r--r-- | remoting/webapp/base/js/format_iq_unittest.js | 118 | ||||
-rw-r--r-- | remoting/webapp/files.gni | 1 |
5 files changed, 37 insertions, 252 deletions
diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index e41ddd6..70f6819 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -93,7 +93,6 @@ 'webapp/base/js/dns_blackhole_checker_unittest.js', 'webapp/base/js/error_unittest.js', 'webapp/base/js/fallback_signal_strategy_unittest.js', - 'webapp/base/js/format_iq_unittest.js', 'webapp/base/js/identity_unittest.js', 'webapp/base/js/ipc_unittest.js', 'webapp/base/js/l10n_unittest.js', diff --git a/remoting/webapp/base/js/chromoting_event.js b/remoting/webapp/base/js/chromoting_event.js index 4aad0f6..69e8a81 100644 --- a/remoting/webapp/base/js/chromoting_event.js +++ b/remoting/webapp/base/js/chromoting_event.js @@ -79,8 +79,7 @@ remoting.ChromotingEvent = function(type) { this.signal_strategy_type; /** @type {remoting.ChromotingEvent.SignalStrategyProgress} */ this.signal_strategy_progress; - /** @type {?remoting.ChromotingEvent.XmppError} */ - this.xmpp_error; + this.init_(); }; @@ -201,25 +200,6 @@ remoting.ChromotingEvent.ConnectionError = { }; /** @enum {number} */ -remoting.ChromotingEvent.XmppErrorType = { - UNKNOWN: 0, - CANCEL: 1, - WAIT: 2, - MODIFY: 3, - AUTH: 4 -}; - -/** @enum {number} */ -remoting.ChromotingEvent.JingleAction = { - UNKNOWN: 0, - SESSION_INITIATE: 1, - SESSION_ACCEPT: 2, - SESSION_TERMINATE: 3, - SESSION_INFO: 4, - TRANSPORT_INFO: 5 -}; - -/** @enum {number} */ remoting.ChromotingEvent.Mode = { IT2ME: 1, ME2ME: 2, @@ -241,23 +221,3 @@ remoting.ChromotingEvent.SignalStrategyProgress = { FAILED_LATE: 5 }; - -/** - * Represents an XMPP Error. - * - * jingle_action: represents the action attribute of the original request. - * - * type: The XMPP error type. - * - * condition_string: The XMPP error condition. - * - * See http://xmpp.org/extensions/xep-0086.html. - * - * @typedef {{ - * jingle_action: remoting.ChromotingEvent.JingleAction, - * type: remoting.ChromotingEvent.XmppErrorType, - * condition_string: string, - * from_client: boolean - * }} - */ -remoting.ChromotingEvent.XmppError; diff --git a/remoting/webapp/base/js/format_iq.js b/remoting/webapp/base/js/format_iq.js index 2ef251c..89a5bbe 100644 --- a/remoting/webapp/base/js/format_iq.js +++ b/remoting/webapp/base/js/format_iq.js @@ -7,13 +7,11 @@ * Module to format IQ messages so they can be displayed in the debug log. */ +'use strict'; + /** @suppress {duplicate} */ var remoting = remoting || {}; -(function() { - -'use strict'; - /** * @constructor * @param {string} clientJid @@ -24,16 +22,6 @@ remoting.FormatIq = function(clientJid, hostJid) { this.clientJid_ = clientJid; /** @private */ this.hostJid_ = hostJid; - /** @private {?remoting.ChromotingEvent.XmppError} */ - this.mostRecentXmppError_ = null; -}; - -/** - * @return {?remoting.ChromotingEvent.XmppError} - */ -remoting.FormatIq.prototype.getMostRecentError = function() { - return /** @type {remoting.ChromotingEvent.XmppError} */ (base.deepCopy( - this.mostRecentXmppError_)); }; /** @@ -201,8 +189,7 @@ remoting.FormatIq.prototype.prettySessionInitiateAccept = function(jingle) { /** @type {Node} */ var desc = desc_children[d]; var dname = desc.nodeName; - if (dname == 'control' || dname == 'event' || dname == 'video' || - dname == 'audio') { + if (dname == 'control' || dname == 'event' || dname == 'video') { var channel_str = this.calcChannelString(desc); if (!channel_str) { return null; @@ -226,6 +213,8 @@ remoting.FormatIq.prototype.prettySessionInitiateAccept = function(jingle) { return null; } } + } else { + return null; } } result += '\n channels: ' + channels; @@ -349,32 +338,39 @@ remoting.FormatIq.prototype.prettyJingleAction = function(jingle, action) { /** * Pretty print the jingle error information contained in the given Xml node. * - * @param {boolean} send True if we're sending this stanza; false for receiving. - * @param {string} jingleAction The Jingle action that the error corresponds to. * @param {Node} error Xml node containing error information in child nodes. * - * @return {?string} Pretty version of error stanza. Null if error. + * @return {?string} Pretty version of error stanze. Null if error. */ -remoting.FormatIq.prototype.prettyError = function(send, jingleAction, error) { +remoting.FormatIq.prototype.prettyError = function(error) { if (!this.verifyAttributes(error, 'xmlns:err,code,type,err:hostname,' + 'err:bnsname,err:stacktrace')) { return null; } var code = error.getAttribute('code'); var type = error.getAttribute('type'); - var condition = (error.firstChild) ? error.firstChild.nodeName : ''; - - // This variable is part of the ChromotingEvent protobuf, which has naming - // convention of variable_name as opposed to variableName. - this.mostRecentXmppError_ = { - jingle_action: toJingleAction(jingleAction), - type: toXmppErrorType(type), - condition_string: condition, - from_client: send - }; - - return '\n error code:' + code + ' type:' + type + ' error-condition:' + - condition; + var hostname = error.getAttribute('err:hostname'); + var bnsname = error.getAttribute('err:bnsname'); + var stacktrace = error.getAttribute('err:stacktrace'); + + var result = '\n error ' + code + ' ' + type + " hostname:'" + + hostname + "' bnsname:'" + bnsname + "'"; + var children = error.childNodes; + for (var i = 0; i < children.length; i++) { + /** @type {Node} */ + var child = children[i]; + result += '\n ' + child.nodeName; + } + if (stacktrace) { + var stack = stacktrace.split(' | '); + result += '\n stacktrace:'; + // We use 'length-1' because the stack trace ends with " | " which results + // in an empty string at the end after the split. + for (var s = 0; s < stack.length - 1; s++) { + result += '\n ' + stack[s]; + } + } + return result; }; /** @@ -572,26 +568,23 @@ remoting.FormatIq.prototype.prettyIqError = function(action, iq_list) { var sid = jingle.getAttribute('sid'); var result = this.prettyIqHeading(action, id, 'error from ' + jingle_action, sid); + var action_str = this.prettyJingleAction(jingle, jingle_action); + if (!action_str) { + return null; + } + result += action_str; /** @type {Node} */ var error = iq_children[1]; - if (error.nodeName != 'error') { + if (error.nodeName != 'cli:error') { return null; } - var error_str = this.prettyError(action == 'send', jingle_action, error); + var error_str = this.prettyError(error); if (!error_str) { return null; } - - var action_str = this.prettyJingleAction(jingle, jingle_action); - if (!action_str) { - return null; - } - - result += action_str; result += error_str; - return result; }; @@ -703,51 +696,3 @@ remoting.FormatIq.prototype.prettifyReceiveIq = function(message) { } return result; }; - -/** - * @param {string} actionString - * @return {!remoting.ChromotingEvent.JingleAction} - */ -function toJingleAction(actionString) { - var JingleAction = remoting.ChromotingEvent.JingleAction; - - switch(actionString.toLowerCase()) { - case 'session-initiate': - return JingleAction.SESSION_INITIATE; - case 'session-accept': - return JingleAction.SESSION_ACCEPT; - case 'session-terminate': - return JingleAction.SESSION_TERMINATE; - case 'session-info': - return JingleAction.SESSION_INFO; - case 'transport-info': - return JingleAction.TRANSPORT_INFO; - default: - console.assert(false, 'Unknown jingle action: ' + actionString); - return JingleAction.UNKNOWN; - } -} - -/** - * @param {string} errorTypeString - * @return {!remoting.ChromotingEvent.XmppErrorType} - */ -function toXmppErrorType(errorTypeString) { - var XmppErrorType = remoting.ChromotingEvent.XmppErrorType; - - switch(errorTypeString.toLowerCase()) { - case 'cancel': - return XmppErrorType.CANCEL; - case 'wait': - return XmppErrorType.WAIT; - case 'modify': - return XmppErrorType.MODIFY; - case 'auth': - return XmppErrorType.AUTH; - default: - console.assert(false, 'Unknown XMPP error type: ' + errorTypeString); - return XmppErrorType.UNKNOWN; - } -} - -})();
\ No newline at end of file diff --git a/remoting/webapp/base/js/format_iq_unittest.js b/remoting/webapp/base/js/format_iq_unittest.js deleted file mode 100644 index 1f94959..0000000 --- a/remoting/webapp/base/js/format_iq_unittest.js +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function() { - -'use strict'; - -/** @type {remoting.FormatIq} */ -var formatter = null; - - -QUnit.module('FormatIq', { - beforeEach: function() { - formatter = new remoting.FormatIq('clientJid', 'hostJid'); - }, - afterEach: function() { - formatter = null; - } -}); - -/** - * @param {QUnit.Assert} assert - * @param {string} xmlString - * @param {boolean} fromClient - * @param {string} jingleAction - * @param {remoting.ChromotingEvent.XmppError} expectedError - */ -function runErrorParserTest(assert, xmlString, fromClient, jingleAction, - expectedError) { - var parser = new DOMParser(); - var xml = parser.parseFromString(xmlString, 'text/xml'); - formatter.prettyError(fromClient, jingleAction, xml.firstChild); - assert.deepEqual(formatter.getMostRecentError(), expectedError); -} - -QUnit.test('prettyError()', function(assert) { - var Event = remoting.ChromotingEvent; - - runErrorParserTest( - assert, - '<error type="cancel">' + - '<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>' + - '</error>', - true, - 'session-initiate', - { - jingle_action: Event.JingleAction.SESSION_INITIATE, - condition_string: 'service-unavailable', - from_client: true, - type: Event.XmppErrorType.CANCEL - } - ); - - runErrorParserTest( - assert, - '<error type="cancel">' + - '<bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>' + - '</error>', - false, - 'SESSION-INFO', - { - jingle_action: Event.JingleAction.SESSION_INFO, - condition_string: 'bad-request', - from_client: false, - type: Event.XmppErrorType.CANCEL - } - ); - - runErrorParserTest( - assert, - '<error type="wait">' + - '<resource-constraint xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>' + - '</error>', - true, - 'session-accept', - { - jingle_action: Event.JingleAction.SESSION_ACCEPT, - condition_string: 'resource-constraint', - from_client: true, - type: Event.XmppErrorType.WAIT - } - ); - - runErrorParserTest( - assert, - '<error type="modify">' + - '<redirect xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">' + - 'xmpp:voicemail@capulet.lit' + - '</redirect>' + - '</error>', - true, - 'transport-info', - { - jingle_action: Event.JingleAction.TRANSPORT_INFO, - condition_string: 'redirect', - from_client: true, - type: Event.XmppErrorType.MODIFY - } - ); - - runErrorParserTest( - assert, - '<error type="auth">' + - '<not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>' + - '</error>', - false, - 'session-terminate', - { - jingle_action: Event.JingleAction.SESSION_TERMINATE, - condition_string: 'not-authorized', - from_client: false, - type: Event.XmppErrorType.AUTH - } - ); -}); - -})(); diff --git a/remoting/webapp/files.gni b/remoting/webapp/files.gni index b9c6e13..140a22e 100644 --- a/remoting/webapp/files.gni +++ b/remoting/webapp/files.gni @@ -90,7 +90,6 @@ remoting_webapp_unittests_js_files = [ "base/js/dns_blackhole_checker_unittest.js", "base/js/error_unittest.js", "base/js/fallback_signal_strategy_unittest.js", - "base/js/format_iq_unittest.js", "base/js/identity_unittest.js", "base/js/ipc_unittest.js", "base/js/l10n_unittest.js", |