Example #1
0
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const Immutable = require("devtools/client/shared/vendor/immutable");

const {
  MESSAGE_SOURCE,
  MESSAGE_TYPE,
  MESSAGE_LEVEL
} = require("devtools/client/webconsole/new-console-output/constants");

exports.ConsoleCommand = Immutable.Record({
  id: null,
  allowRepeating: false,
  messageText: null,
  source: MESSAGE_SOURCE.JAVASCRIPT,
  type: MESSAGE_TYPE.COMMAND,
  level: MESSAGE_LEVEL.LOG,
  groupId: null,
});

exports.ConsoleMessage = Immutable.Record({
  id: null,
  allowRepeating: true,
  source: null,
  type: null,
  level: null,
  messageText: null,
  parameters: null,
  repeat: 1,
  repeatId: null,
Example #2
0
/* 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";

const I = require("devtools/client/shared/vendor/immutable");
const {
  OPEN_SIDEBAR,
  OPEN_STATISTICS,
  WATERFALL_RESIZE,
} = require("../constants");

const UI = I.Record({
  sidebarOpen: false,
  statisticsOpen: false,
  waterfallWidth: null,
});

// Safe bounds for waterfall width (px)
const REQUESTS_WATERFALL_SAFE_BOUNDS = 90;

function resizeWaterfall(state, action) {
  return state.set("waterfallWidth", action.width - REQUESTS_WATERFALL_SAFE_BOUNDS);
}

function openSidebar(state, action) {
  return state.set("sidebarOpen", action.open);
}

function openStatistics(state, action) {
Example #3
0
const Request = I.Record({
  id: null,
  // Set to true in case of a request that's being edited as part of "edit and resend"
  isCustom: false,
  // Request properties - at the beginning, they are unknown and are gradually filled in
  startedMillis: undefined,
  method: undefined,
  url: undefined,
  urlDetails: undefined,
  remotePort: undefined,
  remoteAddress: undefined,
  isXHR: undefined,
  cause: undefined,
  fromCache: undefined,
  fromServiceWorker: undefined,
  status: undefined,
  statusText: undefined,
  httpVersion: undefined,
  securityState: undefined,
  securityInfo: undefined,
  mimeType: "text/plain",
  contentSize: undefined,
  transferredSize: undefined,
  totalTime: undefined,
  eventTimings: undefined,
  headersSize: undefined,
  requestHeaders: undefined,
  requestHeadersFromUploadStream: undefined,
  requestCookies: undefined,
  requestPostData: undefined,
  responseHeaders: undefined,
  responseCookies: undefined,
  responseContent: undefined,
  responseContentDataUri: undefined,
  formDataSections: undefined,
});
Example #4
0
/* -*- 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";

const {
  FILTER_BAR_TOGGLE,
  MESSAGE_ADD,
} = require("devtools/client/webconsole/new-console-output/constants");
const Immutable = require("devtools/client/shared/vendor/immutable");

const UiState = Immutable.Record({
  filterBarVisible: false,
  filteredMessageVisible: false,
  autoscroll: true,
});

function ui(state = new UiState(), action) {
  // Autoscroll should be set for all action types. If the last action was not message
  // add, then turn it off. This prevents us from scrolling after someone toggles a
  // filter, or to the bottom of the attachement when an expandable message at the bottom
  // of the list is expanded. It does depend on the MESSAGE_ADD action being the last in
  // its batch, though.
  state = state.set("autoscroll", action.type == MESSAGE_ADD);

  switch (action.type) {
    case FILTER_BAR_TOGGLE:
      return state.set("filterBarVisible", !state.filterBarVisible);
  }
Example #5
0
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const Immutable = require("devtools/client/shared/vendor/immutable");

const {
  MESSAGE_SOURCE,
  MESSAGE_TYPE,
  MESSAGE_LEVEL
} = require("devtools/client/webconsole/new-console-output/constants");

exports.ConsoleCommand = Immutable.Record({
  id: null,
  allowRepeating: false,
  messageText: null,
  source: MESSAGE_SOURCE.JAVASCRIPT,
  type: MESSAGE_TYPE.COMMAND,
  level: MESSAGE_LEVEL.LOG,
  category: "input",
  severity: MESSAGE_TYPE.LOG,
});

exports.ConsoleMessage = Immutable.Record({
  id: null,
  allowRepeating: true,
  source: null,
  type: null,
  level: null,
  messageText: null,
  parameters: null,
  repeat: 1,
  repeatId: null,
Example #6
0
"use strict";

const I = require("devtools/client/shared/vendor/immutable");
const {
  ENABLE_REQUEST_FILTER_TYPE_ONLY,
  TOGGLE_REQUEST_FILTER_TYPE,
  SET_REQUEST_FILTER_TEXT,
} = require("../constants");

const FilterTypes = I.Record({
  all: false,
  html: false,
  css: false,
  js: false,
  xhr: false,
  fonts: false,
  images: false,
  media: false,
  flash: false,
  ws: false,
  other: false,
});

const Filters = I.Record({
  requestFilterTypes: new FilterTypes({ all: true }),
  requestFilterText: "",
});

function toggleRequestFilterType(state, action) {
  let { filter } = action;
  let newState;
Example #7
0
/* 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";

const Immutable = require("devtools/client/shared/vendor/immutable");
const constants = require("devtools/client/webconsole/new-console-output/constants");
const {isGroupType} = require("devtools/client/webconsole/new-console-output/utils/messages");

const MessageState = Immutable.Record({
  // List of all the messages added to the console.
  messagesById: Immutable.List(),
  // List of the message ids which are opened.
  messagesUiById: Immutable.List(),
  // Map of the form {messageId : tableData}, which represent the data passed
  // as an argument in console.table calls.
  messagesTableDataById: Immutable.Map(),
  // Map of the form {groupMessageId : groupArray},
  // where groupArray is the list of of all the parent groups' ids of the groupMessageId.
  groupsById: Immutable.Map(),
  // Message id of the current group (no corresponding console.groupEnd yet).
  currentGroup: null,
});

function messages(state = new MessageState(), action) {
  const {
    messagesById,
    messagesUiById,
    messagesTableDataById,
    groupsById,
    currentGroup
  } = state;
Example #8
0
/* -*- 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";

const Immutable = require("devtools/client/shared/vendor/immutable");
const constants = require("devtools/client/webconsole/new-console-output/constants");

const MessageState = Immutable.Record({
  messagesById: Immutable.List(),
  messagesUiById: Immutable.List(),
});

function messages(state = new MessageState(), action) {
  const messagesById = state.messagesById;
  const messagesUiById = state.messagesUiById;

  switch (action.type) {
    case constants.MESSAGE_ADD:
      let newMessage = action.message;

      if (newMessage.type === constants.MESSAGE_TYPE.NULL_MESSAGE) {
        return state;
      }

      if (newMessage.allowRepeating && messagesById.size > 0) {
        let lastMessage = messagesById.last();
        if (lastMessage.repeatId === newMessage.repeatId) {
          return state.withMutations(function (record) {
Example #9
0
/* -*- 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";

const Immutable = require("devtools/client/shared/vendor/immutable");
const constants = require("devtools/client/webconsole/new-console-output/constants");

const FilterState = Immutable.Record({
  error: true,
  warn: true,
  info: true,
  log: true,
  searchText: ""
});

function filters(state = new FilterState(), action) {
  switch (action.type) {
    case constants.SEVERITY_FILTER:
      let {filter, toggled} = action;
      return state.set(filter, toggled);
    case constants.FILTERS_CLEAR:
      return new FilterState();
    case constants.MESSAGES_SEARCH:
      let {searchText} = action;
      return state.set("searchText", searchText);
  }

  return state;
Example #10
0
/* -*- 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";

const Immutable = require("devtools/client/shared/vendor/immutable");
const constants = require("devtools/client/webconsole/new-console-output/constants");

const FilterState = Immutable.Record({
  css: false,
  debug: true,
  error: true,
  info: true,
  log: true,
  net: false,
  netxhr: false,
  text: "",
  warn: true,
});

function filters(state = new FilterState(), action) {
  switch (action.type) {
    case constants.FILTER_TOGGLE:
      const {filter} = action;
      const active = !state.get(filter);
      return state.set(filter, active);
    case constants.FILTERS_CLEAR:
      return new FilterState();
    case constants.FILTER_TEXT_SET: