diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/webconsole/new-console-output/components/message-types | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/webconsole/new-console-output/components/message-types')
7 files changed, 420 insertions, 0 deletions
diff --git a/devtools/client/webconsole/new-console-output/components/message-types/console-api-call.js b/devtools/client/webconsole/new-console-output/components/message-types/console-api-call.js new file mode 100644 index 000000000..7200648fa --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/console-api-call.js @@ -0,0 +1,132 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 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/. */ + +"use strict"; + +// React & Redux +const { + createFactory, + DOM: dom, + PropTypes +} = require("devtools/client/shared/vendor/react"); +const GripMessageBody = createFactory(require("devtools/client/webconsole/new-console-output/components/grip-message-body")); +const ConsoleTable = createFactory(require("devtools/client/webconsole/new-console-output/components/console-table")); +const {isGroupType, l10n} = require("devtools/client/webconsole/new-console-output/utils/messages"); + +const Message = createFactory(require("devtools/client/webconsole/new-console-output/components/message")); + +ConsoleApiCall.displayName = "ConsoleApiCall"; + +ConsoleApiCall.propTypes = { + message: PropTypes.object.isRequired, + open: PropTypes.bool, + serviceContainer: PropTypes.object.isRequired, + indent: PropTypes.number.isRequired, +}; + +ConsoleApiCall.defaultProps = { + open: false, + indent: 0, +}; + +function ConsoleApiCall(props) { + const { + dispatch, + message, + open, + tableData, + serviceContainer, + indent, + } = props; + const { + id: messageId, + source, + type, + level, + repeat, + stacktrace, + frame, + parameters, + messageText, + userProvidedStyles, + } = message; + + let messageBody; + if (type === "trace") { + messageBody = dom.span({className: "cm-variable"}, "console.trace()"); + } else if (type === "assert") { + let reps = formatReps(parameters); + messageBody = dom.span({ className: "cm-variable" }, "Assertion failed: ", reps); + } else if (type === "table") { + // TODO: Chrome does not output anything, see if we want to keep this + messageBody = dom.span({className: "cm-variable"}, "console.table()"); + } else if (parameters) { + messageBody = formatReps(parameters, userProvidedStyles, serviceContainer); + } else { + messageBody = messageText; + } + + let attachment = null; + if (type === "table") { + attachment = ConsoleTable({ + dispatch, + id: message.id, + serviceContainer, + parameters: message.parameters, + tableData + }); + } + + let collapseTitle = null; + if (isGroupType(type)) { + collapseTitle = l10n.getStr("groupToggle"); + } + + const collapsible = isGroupType(type) + || (type === "error" && Array.isArray(stacktrace)); + const topLevelClasses = ["cm-s-mozilla"]; + + return Message({ + messageId, + open, + collapsible, + collapseTitle, + source, + type, + level, + topLevelClasses, + messageBody, + repeat, + frame, + stacktrace, + attachment, + serviceContainer, + dispatch, + indent, + }); +} + +function formatReps(parameters, userProvidedStyles, serviceContainer) { + return ( + parameters + // Get all the grips. + .map((grip, key) => GripMessageBody({ + grip, + key, + userProvidedStyle: userProvidedStyles ? userProvidedStyles[key] : null, + serviceContainer + })) + // Interleave spaces. + .reduce((arr, v, i) => { + return i + 1 < parameters.length + ? arr.concat(v, dom.span({}, " ")) + : arr.concat(v); + }, []) + ); +} + +module.exports = ConsoleApiCall; + diff --git a/devtools/client/webconsole/new-console-output/components/message-types/console-command.js b/devtools/client/webconsole/new-console-output/components/message-types/console-command.js new file mode 100644 index 000000000..d87229fa9 --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/console-command.js @@ -0,0 +1,57 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 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/. */ + +"use strict"; + +// React & Redux +const { + createFactory, + PropTypes +} = require("devtools/client/shared/vendor/react"); +const Message = createFactory(require("devtools/client/webconsole/new-console-output/components/message")); + +ConsoleCommand.displayName = "ConsoleCommand"; + +ConsoleCommand.propTypes = { + message: PropTypes.object.isRequired, + autoscroll: PropTypes.bool.isRequired, + indent: PropTypes.number.isRequired, +}; + +ConsoleCommand.defaultProps = { + indent: 0, +}; + +/** + * Displays input from the console. + */ +function ConsoleCommand(props) { + const { autoscroll, indent, message } = props; + const { + source, + type, + level, + messageText: messageBody, + } = message; + + const { + serviceContainer, + } = props; + + const childProps = { + source, + type, + level, + topLevelClasses: [], + messageBody, + scrollToMessage: autoscroll, + serviceContainer, + indent: indent, + }; + return Message(childProps); +} + +module.exports = ConsoleCommand; diff --git a/devtools/client/webconsole/new-console-output/components/message-types/default-renderer.js b/devtools/client/webconsole/new-console-output/components/message-types/default-renderer.js new file mode 100644 index 000000000..d07089531 --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/default-renderer.js @@ -0,0 +1,22 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 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/. */ + +"use strict"; + +// React & Redux +const { + DOM: dom, +} = require("devtools/client/shared/vendor/react"); + +DefaultRenderer.displayName = "DefaultRenderer"; + +function DefaultRenderer(props) { + return dom.div({}, + "This message type is not supported yet." + ); +} + +module.exports = DefaultRenderer; diff --git a/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js b/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js new file mode 100644 index 000000000..992dc62cf --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js @@ -0,0 +1,64 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 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/. */ + +"use strict"; + +// React & Redux +const { + createFactory, + PropTypes +} = require("devtools/client/shared/vendor/react"); +const Message = createFactory(require("devtools/client/webconsole/new-console-output/components/message")); +const GripMessageBody = createFactory(require("devtools/client/webconsole/new-console-output/components/grip-message-body")); + +EvaluationResult.displayName = "EvaluationResult"; + +EvaluationResult.propTypes = { + message: PropTypes.object.isRequired, + indent: PropTypes.number.isRequired, +}; + +EvaluationResult.defaultProps = { + indent: 0, +}; + +function EvaluationResult(props) { + const { message, serviceContainer, indent } = props; + const { + source, + type, + level, + id: messageId, + exceptionDocURL, + frame, + } = message; + + let messageBody; + if (message.messageText) { + messageBody = message.messageText; + } else { + messageBody = GripMessageBody({grip: message.parameters}); + } + + const topLevelClasses = ["cm-s-mozilla"]; + + const childProps = { + source, + type, + level, + indent, + topLevelClasses, + messageBody, + messageId, + scrollToMessage: props.autoscroll, + serviceContainer, + exceptionDocURL, + frame, + }; + return Message(childProps); +} + +module.exports = EvaluationResult; diff --git a/devtools/client/webconsole/new-console-output/components/message-types/moz.build b/devtools/client/webconsole/new-console-output/components/message-types/moz.build new file mode 100644 index 000000000..9b9f72017 --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/moz.build @@ -0,0 +1,13 @@ +# vim: set filetype=python: +# 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/. + +DevToolsModules( + 'console-api-call.js', + 'console-command.js', + 'default-renderer.js', + 'evaluation-result.js', + 'network-event-message.js', + 'page-error.js', +) diff --git a/devtools/client/webconsole/new-console-output/components/message-types/network-event-message.js b/devtools/client/webconsole/new-console-output/components/message-types/network-event-message.js new file mode 100644 index 000000000..e3c81a487 --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/network-event-message.js @@ -0,0 +1,63 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 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/. */ + +"use strict"; + +// React & Redux +const { + createFactory, + DOM: dom, + PropTypes +} = require("devtools/client/shared/vendor/react"); +const Message = createFactory(require("devtools/client/webconsole/new-console-output/components/message")); +const { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages"); + +NetworkEventMessage.displayName = "NetworkEventMessage"; + +NetworkEventMessage.propTypes = { + message: PropTypes.object.isRequired, + serviceContainer: PropTypes.shape({ + openNetworkPanel: PropTypes.func.isRequired, + }), + indent: PropTypes.number.isRequired, +}; + +NetworkEventMessage.defaultProps = { + indent: 0, +}; + +function NetworkEventMessage(props) { + const { message, serviceContainer, indent } = props; + const { actor, source, type, level, request, isXHR } = message; + + const topLevelClasses = [ "cm-s-mozilla" ]; + + function onUrlClick() { + serviceContainer.openNetworkPanel(actor); + } + + const method = dom.span({className: "method" }, request.method); + const xhr = isXHR + ? dom.span({ className: "xhr" }, l10n.getStr("webConsoleXhrIndicator")) + : null; + const url = dom.a({ className: "url", title: request.url, onClick: onUrlClick }, + request.url.replace(/\?.+/, "")); + + const messageBody = dom.span({}, method, xhr, url); + + const childProps = { + source, + type, + level, + indent, + topLevelClasses, + messageBody, + serviceContainer, + }; + return Message(childProps); +} + +module.exports = NetworkEventMessage; diff --git a/devtools/client/webconsole/new-console-output/components/message-types/page-error.js b/devtools/client/webconsole/new-console-output/components/message-types/page-error.js new file mode 100644 index 000000000..77ea75ff7 --- /dev/null +++ b/devtools/client/webconsole/new-console-output/components/message-types/page-error.js @@ -0,0 +1,69 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 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/. */ + +"use strict"; + +// React & Redux +const { + createFactory, + PropTypes +} = require("devtools/client/shared/vendor/react"); +const Message = createFactory(require("devtools/client/webconsole/new-console-output/components/message")); + +PageError.displayName = "PageError"; + +PageError.propTypes = { + message: PropTypes.object.isRequired, + open: PropTypes.bool, + indent: PropTypes.number.isRequired, +}; + +PageError.defaultProps = { + open: false, + indent: 0, +}; + +function PageError(props) { + const { + dispatch, + message, + open, + serviceContainer, + indent, + } = props; + const { + id: messageId, + source, + type, + level, + messageText: messageBody, + repeat, + stacktrace, + frame, + exceptionDocURL, + } = message; + + const childProps = { + dispatch, + messageId, + open, + collapsible: Array.isArray(stacktrace), + source, + type, + level, + topLevelClasses: [], + indent, + messageBody, + repeat, + frame, + stacktrace, + serviceContainer, + exceptionDocURL, + }; + return Message(childProps); +} + +module.exports = PageError; |