Backed out 4 changesets (bug 1524276) for mochitest-devtools failure at devtools/client/webconsole/test/fixtures/stub-generators/browser_webconsole_check_stubs_console_api.js. On a CLOSED TREE

Backed out changeset 47363a80ef6d (bug 1524276)
Backed out changeset 1fee0c357772 (bug 1524276)
Backed out changeset 8bbe3e4f5a54 (bug 1524276)
Backed out changeset d21159afd969 (bug 1524276)
This commit is contained in:
Daniel Varga 2019-03-29 13:47:46 +02:00
Родитель 81b30d7143
Коммит 1380d5ef8d
31 изменённых файлов: 101 добавлений и 1291 удалений

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

@ -344,8 +344,3 @@ webconsole.confirmDialog.getter.label=Invoke getter %S to retrieve the property
# Label used for the confirm button in the "invoke getter" dialog that appears in the
# console when a user tries to autocomplete a property with a getter.
webconsole.confirmDialog.getter.invokeButtonLabel=Invoke
# LOCALIZATION NOTE (webconsole.group.contentBlocked)
# Label used as the group header in the console output when content blocking is enabled
# and that we have several warning messages about resources being blocked.
webconsole.group.contentBlocked=Content blocked messages

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

@ -160,10 +160,6 @@ a {
border-inline-end: solid 1px var(--console-output-indent-border-color);
}
.message > .indent.warning-indent {
border-inline-end-color: var(--warning-color);
}
.message > .indent[data-indent="0"] {
display: none;
}
@ -253,34 +249,23 @@ a {
}
/* The bubble that shows the number of times a message is repeated */
.message-repeats,
.warning-group-badge {
.message-repeats {
flex-shrink: 0;
margin: 2px 5px 0 5px;
padding: 0 6px;
height: 1.25em;
color: white;
background-color: var(--repeat-bubble-background-color);
border-radius: 40px;
font: message-box;
font-size: 0.8em;
font-weight: normal;
}
.message-repeats {
display: inline-block;
color: white;
background-color: var(--repeat-bubble-background-color);
}
.message-repeats[value="1"] {
display: none;
}
.warning-group-badge {
display: inline-block;
color: var(--warning-background-color);
background-color: var(--warning-color);
}
.message-location {
max-width: 40vw;
flex-shrink: 0;

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

@ -16,8 +16,6 @@ const {
getVisibleMessages,
getPausedExecutionPoint,
getAllRepeatById,
getAllWarningGroupsById,
isMessageInWarningGroup,
} = require("devtools/client/webconsole/selectors/messages");
loader.lazyRequireGetter(this, "PropTypes", "devtools/client/shared/vendor/react-prop-types");
@ -60,8 +58,6 @@ class ConsoleOutput extends Component {
timestampsVisible: PropTypes.bool,
messagesTableData: PropTypes.object.isRequired,
messagesRepeat: PropTypes.object.isRequired,
warningGroups: PropTypes.object.isRequired,
isInWarningGroup: PropTypes.isRequired,
networkMessagesUpdate: PropTypes.object.isRequired,
visibleMessages: PropTypes.array.isRequired,
networkMessageActiveTabId: PropTypes.string.isRequired,
@ -175,8 +171,6 @@ class ConsoleOutput extends Component {
messagesUi,
messagesTableData,
messagesRepeat,
warningGroups,
isInWarningGroup,
networkMessagesUpdate,
networkMessageActiveTabId,
serviceContainer,
@ -206,10 +200,6 @@ class ConsoleOutput extends Component {
tableData: messagesTableData.get(messageId),
timestampsVisible,
repeat: messagesRepeat[messageId],
badge: warningGroups.has(messageId) ? warningGroups.get(messageId).length : null,
inWarningGroup: isInWarningGroup
? isInWarningGroup(messages.get(messageId))
: false,
networkMessageUpdate: networkMessagesUpdate[messageId],
networkMessageActiveTabId,
pausedExecutionPoint,
@ -254,10 +244,6 @@ function mapStateToProps(state, props) {
messagesUi: getAllMessagesUiById(state),
messagesTableData: getAllMessagesTableDataById(state),
messagesRepeat: getAllRepeatById(state),
warningGroups: getAllWarningGroupsById(state),
isInWarningGroup: state.prefs.groupWarnings
? message => isMessageInWarningGroup(state, message)
: null,
networkMessagesUpdate: getAllNetworkMessagesUpdateById(state),
timestampsVisible: state.ui.timestampsVisible,
networkMessageActiveTabId: state.ui.networkMessageActiveTabId,

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

@ -31,7 +31,6 @@ class Message extends Component {
type: PropTypes.string.isRequired,
level: PropTypes.string.isRequired,
indent: PropTypes.number.isRequired,
inWarningGroup: PropTypes.bool,
topLevelClasses: PropTypes.array.isRequired,
messageBody: PropTypes.any.isRequired,
repeat: PropTypes.any,
@ -132,17 +131,7 @@ class Message extends Component {
}
renderIcon() {
const {
level,
messageId,
executionPoint,
serviceContainer,
inWarningGroup,
} = this.props;
if (inWarningGroup) {
return undefined;
}
const { level, messageId, executionPoint, serviceContainer } = this.props;
return MessageIcon({
level,
@ -162,7 +151,6 @@ class Message extends Component {
isPaused,
level,
indent,
inWarningGroup,
topLevelClasses,
messageBody,
frame,
@ -313,10 +301,7 @@ class Message extends Component {
"aria-live": type === MESSAGE_TYPE.COMMAND ? "off" : "polite",
},
timestampEl,
MessageIndent({
indent,
inWarningGroup,
}),
MessageIndent({indent}),
icon,
collapse,
dom.span({ className: "message-body-wrapper" },
@ -328,7 +313,7 @@ class Message extends Component {
timestampEl ? " " : null,
dom.span({ className: "message-body devtools-monospace" },
...bodyElements,
learnMore,
learnMore
),
repeat ? " " : null,
repeat,

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

@ -9,7 +9,6 @@
// React & Redux
const { Component } = require("devtools/client/shared/vendor/react");
loader.lazyRequireGetter(this, "PropTypes", "devtools/client/shared/vendor/react-prop-types");
loader.lazyRequireGetter(this, "isWarningGroup", "devtools/client/webconsole/utils/messages", true);
const {
MESSAGE_SOURCE,
@ -23,7 +22,6 @@ const componentMap = new Map([
["EvaluationResult", require("./message-types/EvaluationResult")],
["NetworkEventMessage", require("./message-types/NetworkEventMessage")],
["PageError", require("./message-types/PageError")],
["WarningGroup", require("./message-types/WarningGroup")],
]);
class MessageContainer extends Component {
@ -35,8 +33,6 @@ class MessageContainer extends Component {
tableData: PropTypes.object,
timestampsVisible: PropTypes.bool.isRequired,
repeat: PropTypes.number,
badge: PropTypes.number,
indent: PropTypes.number,
networkMessageUpdate: PropTypes.object,
getMessage: PropTypes.func.isRequired,
isPaused: PropTypes.bool.isRequired,
@ -61,10 +57,8 @@ class MessageContainer extends Component {
const pausedChanged = this.props.isPaused !== nextProps.isPaused;
const executionPointChanged =
this.props.pausedExecutionPoint !== nextProps.pausedExecutionPoint;
const badgeChanged = this.props.badge !== nextProps.badge;
return repeatChanged
|| badgeChanged
|| openChanged
|| tableDataChanged
|| timestampVisibleChanged
@ -107,11 +101,6 @@ function getMessageComponent(message) {
default:
return componentMap.get("DefaultRenderer");
}
case MESSAGE_SOURCE.CONSOLE_FRONTEND:
if (isWarningGroup(message)) {
return componentMap.get("WarningGroup");
}
break;
}
return componentMap.get("DefaultRenderer");

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

@ -10,14 +10,14 @@ const dom = require("devtools/client/shared/vendor/react-dom-factories");
const INDENT_WIDTH = 12;
// Store common indents so they can be used without recreating the element during render.
// Store common indents so they can be used without recreating the element
// during render.
const CONSTANT_INDENTS = [getIndentElement(0), getIndentElement(1)];
const IN_WARNING_GROUP_INDENT = getIndentElement(1, "warning-indent");
function getIndentElement(indent, className) {
function getIndentElement(indent) {
return dom.span({
"data-indent": indent,
className: `indent${className ? " " + className : ""}`,
className: "indent",
style: {
"width": indent * INDENT_WIDTH,
},
@ -25,12 +25,7 @@ function getIndentElement(indent, className) {
}
function MessageIndent(props) {
const { indent, inWarningGroup } = props;
if (inWarningGroup) {
return IN_WARNING_GROUP_INDENT;
}
const { indent } = props;
return CONSTANT_INDENTS[indent] || getIndentElement(indent);
}

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

@ -19,7 +19,6 @@ PageError.propTypes = {
timestampsVisible: PropTypes.bool.isRequired,
serviceContainer: PropTypes.object,
maybeScrollToBottom: PropTypes.func,
inWarningGroup: PropTypes.bool.isRequired,
};
PageError.defaultProps = {
@ -36,11 +35,11 @@ function PageError(props) {
timestampsVisible,
isPaused,
maybeScrollToBottom,
inWarningGroup,
} = props;
const {
id: messageId,
executionPoint,
indent,
source,
type,
level,
@ -70,8 +69,7 @@ function PageError(props) {
type,
level,
topLevelClasses: [],
indent: message.indent,
inWarningGroup,
indent,
messageBody,
repeat,
frame,

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

@ -1,73 +0,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";
// React & Redux
const { createFactory } = require("devtools/client/shared/vendor/react");
const dom = require("devtools/client/shared/vendor/react-dom-factories");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const Message = createFactory(require("devtools/client/webconsole/components/Message"));
WarningGroup.displayName = "WarningGroup";
WarningGroup.propTypes = {
dispatch: PropTypes.func.isRequired,
message: PropTypes.object.isRequired,
timestampsVisible: PropTypes.bool.isRequired,
serviceContainer: PropTypes.object,
badge: PropTypes.number.isRequired,
};
function WarningGroup(props) {
const {
dispatch,
message,
serviceContainer,
timestampsVisible,
badge,
open,
} = props;
const {
source,
type,
level,
id: messageId,
indent,
timeStamp,
} = message;
const messageBody = [
message.messageText,
" ",
dom.span({
className: "warning-group-badge",
title: `${badge} messages`,
}, badge),
];
const topLevelClasses = ["cm-s-mozilla"];
return Message({
badge,
collapsible: true,
dispatch,
indent,
level,
messageBody,
messageId,
open,
serviceContainer,
source,
timeStamp,
timestampsVisible,
topLevelClasses,
type,
});
}
module.exports = WarningGroup;

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

@ -10,5 +10,4 @@ DevToolsModules(
'EvaluationResult.js',
'NetworkEventMessage.js',
'PageError.js',
'WarningGroup.js',
)

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

@ -73,7 +73,6 @@ const prefs = {
SIDEBAR_TOGGLE: "devtools.webconsole.sidebarToggle",
JSTERM_CODE_MIRROR: "devtools.webconsole.jsterm.codeMirror",
AUTOCOMPLETE: "devtools.webconsole.input.autocomplete",
GROUP_WARNINGS: "devtools.webconsole.groupWarningMessages",
},
},
};
@ -112,9 +111,6 @@ const chromeRDPEnums = {
JAVASCRIPT: "javascript",
NETWORK: "network",
CONSOLE_API: "console-api",
// Messages emitted by the console frontend itself (i.e. similar messages grouping
// header).
CONSOLE_FRONTEND: "console-frontend",
STORAGE: "storage",
APPCACHE: "appcache",
RENDERING: "rendering",
@ -131,9 +127,6 @@ const chromeRDPEnums = {
START_GROUP: "startGroup",
START_GROUP_COLLAPSED: "startGroupCollapsed",
END_GROUP: "endGroup",
CONTENT_BLOCKING_GROUP: "contentBlockingWarningGroup",
CORS_GROUP: "CORSWarningGroup",
CSP_GROUP: "CSPWarningGroup",
ASSERT: "assert",
DEBUG: "debug",
PROFILE: "profile",

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

@ -21,10 +21,6 @@ const {
loader.lazyRequireGetter(this, "getGripPreviewItems", "devtools/client/shared/components/reps/reps", true);
loader.lazyRequireGetter(this, "getUnicodeUrlPath", "devtools/client/shared/unicode-url", true);
loader.lazyRequireGetter(this, "getSourceNames", "devtools/client/shared/source-utils", true);
loader.lazyRequireGetter(this, "createWarningGroupMessage", "devtools/client/webconsole/utils/messages", true);
loader.lazyRequireGetter(this, "isWarningGroup", "devtools/client/webconsole/utils/messages", true);
loader.lazyRequireGetter(this, "getWarningGroupType", "devtools/client/webconsole/utils/messages", true);
loader.lazyRequireGetter(this, "getParentWarningGroupMessageId", "devtools/client/webconsole/utils/messages", true);
const {
UPDATE_REQUEST,
@ -50,12 +46,9 @@ const MessageState = overrides => Object.freeze(Object.assign({
messagesTableDataById: new Map(),
// Map of the form {groupMessageId : groupArray},
// where groupArray is the list of of all the parent groups' ids of the groupMessageId.
// This handles console API groups.
groupsById: new Map(),
// Message id of the current console API group (no corresponding console.groupEnd yet).
// Message id of the current group (no corresponding console.groupEnd yet).
currentGroup: null,
// This group handles "warning groups" (Content Blocking, CORS, CSP, …)
warningGroupsById: new Map(),
// Array of removed actors (i.e. actors logged in removed messages) we keep track of
// in order to properly release them.
// This array is not supposed to be consumed by any UI component.
@ -85,20 +78,10 @@ function cloneState(state) {
networkMessagesUpdateById: {...state.networkMessagesUpdateById},
removedLogpointIds: new Set(state.removedLogpointIds),
pausedExecutionPoint: state.pausedExecutionPoint,
warningGroupsById: new Map(state.warningGroupsById),
};
}
/**
* Add a console message to the state.
*
* @param {ConsoleMessage} newMessage: The message to add to the state.
* @param {MessageState} state: The message state ( = managed by this reducer).
* @param {FiltersState} filtersState: The filters state.
* @param {PrefsState} prefsState: The preferences state.
* @returns {MessageState} a new messages state.
*/
function addMessage(newMessage, state, filtersState, prefsState) {
function addMessage(state, filtersState, prefsState, newMessage) {
const {
messagesById,
replayProgressMessages,
@ -138,7 +121,7 @@ function addMessage(newMessage, state, filtersState, prefsState) {
}
if (newMessage.allowRepeating && messagesById.size > 0) {
const lastMessage = messagesById.get(getLastMessageId(state));
const lastMessage = [...messagesById.values()][messagesById.size - 1];
if (
lastMessage.repeatId === newMessage.repeatId
@ -156,47 +139,6 @@ function addMessage(newMessage, state, filtersState, prefsState) {
ensureExecutionPoint(state, newMessage);
// Check if the current message could be placed in a Warning Group.
// This needs to be done before setting the new message in messagesById so we have a
// proper message.
const warningGroupType = getWarningGroupType(newMessage);
// If the preference for warning grouping is true, and the new message could be in a
// warning group.
if (prefsState.groupWarnings && warningGroupType !== null) {
const warningGroupMessageId = getParentWarningGroupMessageId(newMessage);
// If there's no warning group for the type/innerWindowID yet
if (!state.messagesById.has(warningGroupMessageId)) {
// We create it and add it to the store.
const groupMessage = createWarningGroupMessage(
warningGroupMessageId, warningGroupType, newMessage);
state = addMessage(groupMessage, state, filtersState, prefsState);
state.warningGroupsById.set(warningGroupMessageId, []);
}
// We add the new message to the appropriate warningGroup.
state.warningGroupsById.get(warningGroupMessageId).push(newMessage.id);
// If the warningGroup message is not visible yet, but should be.
if (!state.visibleMessages.includes(warningGroupMessageId)
&& getMessageVisibility(state.messagesById.get(warningGroupMessageId), {
messagesState: state,
filtersState,
prefsState,
}).visible
) {
// Then we put it in the visibleMessages properties, at the position of the first
// warning message inside the warningGroup.
// TODO [Bug 1534927]: It should be added before the outermost console.group message
// a warning message could be in.
const index = state
.visibleMessages
.indexOf(state.warningGroupsById.get(warningGroupMessageId)[0]);
state.visibleMessages.splice(index, 1, warningGroupMessageId);
}
}
const addedMessage = Object.freeze(newMessage);
state.messagesById.set(newMessage.id, addedMessage);
@ -213,35 +155,13 @@ function addMessage(newMessage, state, filtersState, prefsState) {
}
}
const { visible, cause } = getMessageVisibility(addedMessage, {
messagesState: state,
filtersState,
prefsState,
});
const {
visible,
cause,
} = getMessageVisibility(addedMessage, state, filtersState);
if (visible) {
// If the message is part of a visible warning group, we want to add it after the last
// visible message of the group.
const warningGroupId = getParentWarningGroupMessageId(newMessage);
if (warningGroupId && state.visibleMessages.includes(warningGroupId)) {
// Defaults to the warning group message.
let index = state.visibleMessages.indexOf(warningGroupId);
// We loop backward through the warning group's messages to get the latest visible
// messages in it.
const messagesInWarningGroup = state.warningGroupsById.get(warningGroupId);
for (let i = messagesInWarningGroup.length - 1; i >= 0; i--) {
const idx = state.visibleMessages.indexOf(messagesInWarningGroup[i]);
if (idx > -1) {
index = idx;
break;
}
}
// Inserts the new warning message at the wanted location "in" the warning group.
state.visibleMessages.splice(index + 1, 0, newMessage.id);
} else {
state.visibleMessages.push(newMessage.id);
}
state.visibleMessages.push(newMessage.id);
maybeSortVisibleMessages(state);
} else if (DEFAULT_FILTERS.includes(cause)) {
state.filteredMessagesCount.global++;
@ -302,7 +222,7 @@ function messages(state = MessageState(), action, filtersState, prefsState) {
newState = cloneState(state);
list.forEach(message => {
newState = addMessage(message, newState, filtersState, prefsState);
newState = addMessage(newState, filtersState, prefsState, message);
});
return limitTopLevelMessageCount(newState, logLimit);
@ -358,27 +278,21 @@ function messages(state = MessageState(), action, filtersState, prefsState) {
openState.messagesUiById = [...messagesUiById, action.id];
const currMessage = messagesById.get(action.id);
// If the message is a console.group/groupCollapsed or a warning group.
if (isGroupType(currMessage.type) || isWarningGroup(currMessage)) {
// If the message is a group
if (isGroupType(currMessage.type)) {
// We want to make its children visible
const messagesToShow = [...messagesById].reduce((res, [id, message]) => {
if (
!visibleMessages.includes(message.id)
&& (
(isWarningGroup(currMessage) && !!getWarningGroupType(message))
|| (
isGroupType(currMessage.type)
&& getParentGroups(message.groupId, groupsById).includes(action.id)
)
)
&& getMessageVisibility(message, {
messagesState: openState,
&& getParentGroups(message.groupId, groupsById).includes(action.id)
&& getMessageVisibility(
message,
openState,
filtersState,
prefsState,
// We want to check if the message is in an open group
// only if it is not a direct child of the group we're opening.
checkGroup: message.groupId !== action.id,
}).visible
// We want to check if the message is in an open group
// only if it is not a direct child of the group we're opening.
message.groupId !== action.id
).visible
) {
res.push(id);
}
@ -420,11 +334,6 @@ function messages(state = MessageState(), action, filtersState, prefsState) {
getParentGroups(messagesById.get(id).groupId, groupsById)
.includes(messageId) === false
);
} else if (isWarningGroup(messagesById.get(messageId))) {
// If the message was a warningGroup, we hide all the messages in the group.
const groupMessages = closeState.warningGroupsById.get(messageId);
closeState.visibleMessages =
visibleMessages.filter(id => !groupMessages.includes(id));
}
return closeState;
@ -478,12 +387,10 @@ function messages(state = MessageState(), action, filtersState, prefsState) {
const filtered = getDefaultFiltersCounter();
messagesById.forEach((message, msgId) => {
const { visible, cause } = getMessageVisibility(message, {
messagesState: state,
filtersState,
prefsState,
});
const {
visible,
cause,
} = getMessageVisibility(message, state, filtersState);
if (visible) {
messagesToShow.push(msgId);
} else if (DEFAULT_FILTERS.includes(cause)) {
@ -728,12 +635,7 @@ function getToplevelMessageCount(state) {
* - visible {Boolean}: true if the message should be visible
* - cause {String}: if visible is false, what causes the message to be hidden.
*/
function getMessageVisibility(message, {
messagesState,
filtersState,
prefsState,
checkGroup = true,
}) {
function getMessageVisibility(message, messagesState, filtersState, checkGroup = true) {
// Do not display the message if it's in closed group.
if (
checkGroup
@ -745,30 +647,6 @@ function getMessageVisibility(message, {
};
}
// If the message is a warningGroup, check if it should be displayed.
if (
isWarningGroup(message)
&& !shouldGroupWarningMessages(message, messagesState, prefsState)
) {
return {
visible: false,
cause: "warningGroupHeuristicNotMet",
};
}
// Do not display the the message if it can be in a warningGroup, and the group is
// displayed but collapsed.
const warningGroupMessageId = getParentWarningGroupMessageId(message);
if (
messagesState.visibleMessages.includes(warningGroupMessageId)
&& !messagesState.messagesUiById.includes(warningGroupMessageId)
) {
return {
visible: false,
cause: "closedWarningGroup",
};
}
// Some messages can't be filtered out (e.g. groups).
// So, always return visible: true for those.
if (isUnfilterable(message)) {
@ -1171,28 +1049,6 @@ function maybeSortVisibleMessages(state) {
}
}
function getLastMessageId(state) {
return Array.from(state.messagesById.keys())[state.messagesById.size - 1];
}
/**
* Returns if a given type of warning message should be grouped.
*
* @param {ConsoleMessage} warningGroupMessage
* @param {MessageState} messagesState
* @param {PrefsState} prefsState
*/
function shouldGroupWarningMessages(warningGroupMessage, messagesState, prefsState) {
// Only group if the preference is ON.
if (!prefsState.groupWarnings) {
return false;
}
// We group warning messages if there are at least 2 messages that could go in it.
const warningGroup = messagesState.warningGroupsById.get(warningGroupMessage.id);
return warningGroup && warningGroup.length > 1;
}
exports.messages = messages;
// Export for testing purpose.

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

@ -9,7 +9,6 @@ const PrefState = (overrides) => Object.freeze(Object.assign({
logLimit: 1000,
sidebarToggle: false,
jstermCodeMirror: false,
groupWarnings: false,
historyCount: 50,
}, overrides));

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

@ -5,9 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
loader.lazyRequireGetter(this, "getWarningGroupType", "devtools/client/webconsole/utils/messages", true);
loader.lazyRequireGetter(this, "getParentWarningGroupMessageId", "devtools/client/webconsole/utils/messages", true);
function getAllMessagesById(state) {
return state.messages.messagesById;
}
@ -56,21 +53,8 @@ function getPausedExecutionPoint(state) {
return state.messages.pausedExecutionPoint;
}
function getAllWarningGroupsById(state) {
return state.messages.warningGroupsById;
}
function isMessageInWarningGroup(state, message) {
if (!getWarningGroupType(message)) {
return false;
}
return getVisibleMessages(state).includes(getParentWarningGroupMessageId(message));
}
module.exports = {
getAllGroupsById,
getAllWarningGroupsById,
getAllMessagesById,
getAllMessagesTableDataById,
getAllMessagesUiById,
@ -82,5 +66,4 @@ module.exports = {
getMessage,
getVisibleMessages,
getPausedExecutionPoint,
isMessageInWarningGroup,
};

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

@ -50,7 +50,6 @@ function configureStore(webConsoleUI, options = {}) {
const sidebarToggle = getBoolPref(PREFS.FEATURES.SIDEBAR_TOGGLE);
const jstermCodeMirror = getBoolPref(PREFS.FEATURES.JSTERM_CODE_MIRROR);
const autocomplete = getBoolPref(PREFS.FEATURES.AUTOCOMPLETE);
const groupWarnings = getBoolPref(PREFS.FEATURES.GROUP_WARNINGS);
const historyCount = getIntPref(PREFS.UI.INPUT_HISTORY_COUNT);
const initialState = {
@ -60,7 +59,6 @@ function configureStore(webConsoleUI, options = {}) {
jstermCodeMirror,
autocomplete,
historyCount,
groupWarnings,
}),
filters: FilterState({
error: getBoolPref(PREFS.FILTER.ERROR),

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

@ -1,75 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test utils.
const expect = require("expect");
const { render } = require("enzyme");
// Components under test.
const WarningGroup = require("devtools/client/webconsole/components/message-types/WarningGroup");
const { MESSAGE_SOURCE, MESSAGE_TYPE } = require("devtools/client/webconsole/constants");
const { ConsoleMessage } = require("devtools/client/webconsole/types");
const { createWarningGroupMessage } = require("devtools/client/webconsole/utils/messages");
// Test fakes.
const { stubPreparedMessages } = require("devtools/client/webconsole/test/fixtures/stubs/index");
const serviceContainer = require("devtools/client/webconsole/test/fixtures/serviceContainer");
const mockMessage = ConsoleMessage({
messageText: "this is a warning group",
source: MESSAGE_SOURCE.CONSOLE_FRONTEND,
timeStamp: Date.now(),
});
describe("WarningGroup component:", () => {
it("renders", () => {
const wrapper = render(WarningGroup({
message: mockMessage,
serviceContainer,
timestampsVisible: true,
badge: 42,
}));
const { timestampString } = require("devtools/client/webconsole/webconsole-l10n");
expect(wrapper.find(".timestamp").text())
.toBe(timestampString(mockMessage.timeStamp));
expect(wrapper.find(".message-body").text()).toBe("this is a warning group 42");
expect(wrapper.find(".arrow[aria-expanded=false]")).toExist();
});
it("does have an expanded arrow when `open` prop is true", () => {
const wrapper = render(WarningGroup({
message: mockMessage,
serviceContainer,
open: true,
}));
expect(wrapper.find(".arrow[aria-expanded=true]")).toExist();
});
it("does not have a timestamp when timestampsVisible prop is falsy", () => {
const wrapper = render(WarningGroup({
message: mockMessage,
serviceContainer,
timestampsVisible: false,
}));
expect(wrapper.find(".timestamp").length).toBe(0);
});
it("renders Content Blocking Group message", () => {
const firstMessage = stubPreparedMessages.get("ReferenceError: asdf is not defined");
const type = MESSAGE_TYPE.CONTENT_BLOCKING_GROUP;
const message = createWarningGroupMessage(`${type}-${firstMessage.innerWindowID}`,
type, firstMessage);
const wrapper = render(WarningGroup({
message,
serviceContainer,
badge: 24,
}));
expect(wrapper.find(".message-body").text()).toBe("Content blocked messages 24");
expect(wrapper.find(".arrow[aria-expanded=false]")).toExist();
});
});

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

@ -41,8 +41,6 @@ class L10n {
return "#1 repeat;#1 repeats";
case "webconsole.filteredMessages.label":
return "#1 item hidden by filters;#1 items hidden by filters";
case "webconsole.group.contentBlocked":
return "Content blocked messages";
default:
return str;
}

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

@ -62,10 +62,6 @@ function getCleanedPacket(key, packet) {
res.timeStamp = existingPacket.timeStamp;
}
if (res.innerWindowID) {
res.innerWindowID = existingPacket.innerWindowID;
}
if (res.startedDateTime) {
res.startedDateTime = existingPacket.startedDateTime;
}
@ -175,9 +171,8 @@ function getCleanedPacket(key, packet) {
}
if (res.pageError) {
// Clean timeStamp and innerWindowID on pageError messages.
// Clean timeStamp on pageError messages.
res.pageError.timeStamp = existingPacket.pageError.timeStamp;
res.pageError.innerWindowID = existingPacket.pageError.innerWindowID;
if (
typeof res.pageError.errorMessage === "object"

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -15,14 +15,12 @@ const stubPreparedMessages = new Map();
const stubPackets = new Map();
stubPreparedMessages.set(`Unknown property such-unknown-property. Declaration dropped.`, new ConsoleMessage({
"id": "1",
"innerWindowID": 15032385539,
"allowRepeating": true,
"source": "css",
"timeStamp": 1479159920406,
"type": "log",
"helperType": null,
"level": "warn",
"category": "CSS Parser",
"messageText": "Unknown property such-unknown-property. Declaration dropped.",
"parameters": null,
"repeatId": "{\"frame\":{\"source\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-css-message.html\",\"sourceId\":null,\"line\":3,\"column\":25},\"groupId\":null,\"indent\":0,\"level\":\"warn\",\"messageText\":\"Unknown property such-unknown-property. Declaration dropped.\",\"parameters\":null,\"source\":\"css\",\"type\":\"log\",\"userProvidedStyles\":null,\"private\":false,\"stacktrace\":null}",
@ -44,14 +42,12 @@ stubPreparedMessages.set(`Unknown property such-unknown-property. Declara
stubPreparedMessages.set(`Error in parsing value for padding-top. Declaration dropped.`, new ConsoleMessage({
"id": "1",
"innerWindowID": 15032385539,
"allowRepeating": true,
"source": "css",
"timeStamp": 1479159920465,
"type": "log",
"helperType": null,
"level": "warn",
"category": "CSS Parser",
"messageText": "Error in parsing value for padding-top. Declaration dropped.",
"parameters": null,
"repeatId": "{\"frame\":{\"source\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-css-message.html\",\"sourceId\":null,\"line\":3,\"column\":16},\"groupId\":null,\"indent\":0,\"level\":\"warn\",\"messageText\":\"Error in parsing value for padding-top. Declaration dropped.\",\"parameters\":null,\"source\":\"css\",\"type\":\"log\",\"userProvidedStyles\":null,\"private\":false,\"stacktrace\":null}",
@ -81,7 +77,6 @@ stubPackets.set(`Unknown property such-unknown-property. Declaration drop
"lineNumber": 3,
"columnNumber": 25,
"category": "CSS Parser",
"innerWindowID": 15032385539,
"timeStamp": 1479159920406,
"warning": true,
"error": false,
@ -106,7 +101,6 @@ stubPackets.set(`Error in parsing value for padding-top. Declaration drop
"lineNumber": 3,
"columnNumber": 16,
"category": "CSS Parser",
"innerWindowID": 15032385539,
"timeStamp": 1479159920465,
"warning": true,
"error": false,

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

@ -15,14 +15,12 @@ const stubPreparedMessages = new Map();
const stubPackets = new Map();
stubPreparedMessages.set(`new Date(0)`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1479159921364,
"type": "result",
"helperType": null,
"level": "log",
"category": null,
"parameters": [
{
"type": "object",
@ -49,14 +47,12 @@ stubPreparedMessages.set(`new Date(0)`, new ConsoleMessage({
stubPreparedMessages.set(`asdf()`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1479159921377,
"type": "result",
"helperType": null,
"level": "error",
"category": null,
"messageText": "ReferenceError: asdf is not defined",
"parameters": [
{
@ -81,14 +77,12 @@ stubPreparedMessages.set(`asdf()`, new ConsoleMessage({
stubPreparedMessages.set(`1 + @`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1479159921399,
"type": "result",
"helperType": null,
"level": "error",
"category": null,
"messageText": "SyntaxError: illegal character",
"parameters": [
{
@ -113,14 +107,12 @@ stubPreparedMessages.set(`1 + @`, new ConsoleMessage({
stubPreparedMessages.set(`inspect({a: 1})`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1499776070751,
"type": "result",
"helperType": "inspectObject",
"level": "log",
"category": null,
"parameters": [
{
"type": "object",
@ -159,14 +151,12 @@ stubPreparedMessages.set(`inspect({a: 1})`, new ConsoleMessage({
stubPreparedMessages.set(`cd(document)`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1510650094657,
"type": "result",
"helperType": "error",
"level": "error",
"category": null,
"messageText": "Cannot cd() to the given window. Invalid argument.",
"parameters": [
{
@ -185,14 +175,12 @@ stubPreparedMessages.set(`cd(document)`, new ConsoleMessage({
stubPreparedMessages.set(`undefined`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1518606917356,
"type": "result",
"helperType": null,
"level": "log",
"category": null,
"parameters": [
{
"type": "undefined"
@ -210,14 +198,12 @@ stubPreparedMessages.set(`undefined`, new ConsoleMessage({
stubPreparedMessages.set(`longString message Error`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1493108241073,
"type": "result",
"helperType": null,
"level": "error",
"category": null,
"messageText": {
"type": "longString",
"initial": "Error: Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Lon",
@ -241,14 +227,12 @@ stubPreparedMessages.set(`longString message Error`, new ConsoleMessage({
stubPreparedMessages.set(`eval throw ""`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1517990289517,
"type": "result",
"helperType": null,
"level": "error",
"category": null,
"messageText": "Error",
"parameters": [
{
@ -267,14 +251,12 @@ stubPreparedMessages.set(`eval throw ""`, new ConsoleMessage({
stubPreparedMessages.set(`eval throw "tomato"`, new ConsoleMessage({
"id": "1",
"innerWindowID": null,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1517990289520,
"type": "result",
"helperType": null,
"level": "error",
"category": null,
"messageText": "Error: tomato",
"parameters": [
{

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

@ -15,14 +15,12 @@ const stubPreparedMessages = new Map();
const stubPackets = new Map();
stubPreparedMessages.set(`ReferenceError: asdf is not defined`, new ConsoleMessage({
"id": "1",
"innerWindowID": 6442450949,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1476573167137,
"type": "log",
"helperType": null,
"level": "error",
"category": "content javascript",
"messageText": "ReferenceError: asdf is not defined",
"parameters": null,
"repeatId": "{\"frame\":{\"source\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-console-api.html\",\"sourceId\":null,\"line\":3,\"column\":5},\"groupId\":null,\"indent\":0,\"level\":\"error\",\"messageText\":\"ReferenceError: asdf is not defined\",\"parameters\":null,\"source\":\"javascript\",\"type\":\"log\",\"userProvidedStyles\":null,\"private\":false,\"stacktrace\":[{\"filename\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-console-api.html\",\"sourceId\":\"server1.conn0.child1/source25\",\"lineNumber\":3,\"columnNumber\":5,\"functionName\":\"bar\"},{\"filename\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-console-api.html\",\"sourceId\":\"server1.conn0.child1/source25\",\"lineNumber\":6,\"columnNumber\":5,\"functionName\":\"foo\"},{\"filename\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-console-api.html\",\"sourceId\":\"server1.conn0.child1/source25\",\"lineNumber\":9,\"columnNumber\":3,\"functionName\":null},{\"filename\":\"resource://testing-common/content-task.js line 59 > eval\",\"sourceId\":null,\"lineNumber\":7,\"columnNumber\":31,\"functionName\":null},{\"filename\":\"resource://testing-common/content-task.js\",\"sourceId\":null,\"lineNumber\":60,\"columnNumber\":29,\"functionName\":null}]}",
@ -81,14 +79,12 @@ stubPreparedMessages.set(`ReferenceError: asdf is not defined`, new ConsoleMessa
stubPreparedMessages.set(`SyntaxError: redeclaration of let a`, new ConsoleMessage({
"id": "1",
"innerWindowID": 6442450949,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1487992945524,
"type": "log",
"helperType": null,
"level": "error",
"category": "content javascript",
"messageText": "SyntaxError: redeclaration of let a",
"parameters": null,
"repeatId": "{\"frame\":{\"source\":\"http://example.com/browser/devtools/client/webconsole/test/fixtures/stub-generators/test-console-api.html\",\"sourceId\":null,\"line\":2,\"column\":9},\"groupId\":null,\"indent\":0,\"level\":\"error\",\"messageText\":\"SyntaxError: redeclaration of let a\",\"parameters\":null,\"source\":\"javascript\",\"type\":\"log\",\"userProvidedStyles\":null,\"private\":false,\"stacktrace\":[{\"filename\":\"resource://testing-common/content-task.js line 59 > eval\",\"sourceId\":null,\"lineNumber\":7,\"columnNumber\":31,\"functionName\":null},{\"filename\":\"resource://testing-common/content-task.js\",\"sourceId\":null,\"lineNumber\":60,\"columnNumber\":29,\"functionName\":null}]}",
@ -136,14 +132,12 @@ stubPreparedMessages.set(`SyntaxError: redeclaration of let a`, new ConsoleMessa
stubPreparedMessages.set(`TypeError longString message`, new ConsoleMessage({
"id": "1",
"innerWindowID": 6442450949,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1493109507061,
"type": "log",
"helperType": null,
"level": "error",
"category": "content javascript",
"messageText": {
"type": "longString",
"initial": "Error: Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Lon",
@ -192,14 +186,12 @@ stubPreparedMessages.set(`TypeError longString message`, new ConsoleMessage({
stubPreparedMessages.set(`throw ""`, new ConsoleMessage({
"id": "1",
"innerWindowID": 6442450949,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1517942398629,
"type": "log",
"helperType": null,
"level": "error",
"category": "content javascript",
"messageText": "uncaught exception: ",
"parameters": null,
"repeatId": "{\"frame\":null,\"groupId\":null,\"indent\":0,\"level\":\"error\",\"messageText\":\"uncaught exception: \",\"parameters\":null,\"source\":\"javascript\",\"type\":\"log\",\"userProvidedStyles\":null,\"private\":false,\"stacktrace\":null}",
@ -216,14 +208,12 @@ stubPreparedMessages.set(`throw ""`, new ConsoleMessage({
stubPreparedMessages.set(`throw "tomato"`, new ConsoleMessage({
"id": "1",
"innerWindowID": 6442450949,
"allowRepeating": true,
"source": "javascript",
"timeStamp": 1517942398637,
"type": "log",
"helperType": null,
"level": "error",
"category": "content javascript",
"messageText": "uncaught exception: tomato",
"parameters": null,
"repeatId": "{\"frame\":null,\"groupId\":null,\"indent\":0,\"level\":\"error\",\"messageText\":\"uncaught exception: tomato\",\"parameters\":null,\"source\":\"javascript\",\"type\":\"log\",\"userProvidedStyles\":null,\"private\":false,\"stacktrace\":null}",
@ -249,7 +239,6 @@ stubPackets.set(`ReferenceError: asdf is not defined`, {
"lineNumber": 3,
"columnNumber": 5,
"category": "content javascript",
"innerWindowID": 6442450949,
"timeStamp": 1476573167137,
"warning": false,
"error": false,
@ -311,7 +300,6 @@ stubPackets.set(`SyntaxError: redeclaration of let a`, {
"lineNumber": 2,
"columnNumber": 9,
"category": "content javascript",
"innerWindowID": 6442450949,
"timeStamp": 1487992945524,
"warning": false,
"error": false,
@ -366,7 +354,6 @@ stubPackets.set(`TypeError longString message`, {
"lineNumber": 1,
"columnNumber": 7,
"category": "content javascript",
"innerWindowID": 6442450949,
"timeStamp": 1493109507061,
"warning": false,
"error": false,
@ -413,7 +400,6 @@ stubPackets.set(`throw ""`, {
"lineNumber": 0,
"columnNumber": 0,
"category": "content javascript",
"innerWindowID": 6442450949,
"timeStamp": 1517942398629,
"warning": false,
"error": false,
@ -438,7 +424,6 @@ stubPackets.set(`throw "tomato"`, {
"lineNumber": 0,
"columnNumber": 0,
"category": "content javascript",
"innerWindowID": 6442450949,
"timeStamp": 1517942398637,
"warning": false,
"error": false,

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

@ -24,8 +24,6 @@ pref("devtools.webconsole.persistlog", false);
pref("devtools.webconsole.timestampMessages", false);
pref("devtools.webconsole.sidebarToggle", true);
pref("devtools.webconsole.jsterm.codeMirror", true);
pref("devtools.webconsole.groupWarningMessages", false);
pref("devtools.webconsole.input.editor", false);
global.loader = {
lazyServiceGetter: () => {},

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

@ -115,7 +115,6 @@ support-files =
test-subresource-security-error.js^headers^
test-time-methods.html
test-trackingprotection-securityerrors.html
test-warning-groups.html
test-webconsole-error-observer.html
test-websocket.html
test-websocket.js
@ -398,6 +397,4 @@ tags = trackingprotection
[browser_webconsole_view_source.js]
[browser_webconsole_visibility_messages.js]
[browser_webconsole_warn_about_replaced_api.js]
[browser_webconsole_warning_group_content_blocking.js]
[browser_webconsole_warning_groups.js]
[browser_webconsole_websocket.js]

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

@ -118,6 +118,14 @@ add_task(async function testCookieBlockedByPermissionMessage() {
Services.perms.removeFromPrincipal(p, "cookie");
});
async function openNewWindowAndConsole(url) {
const win = await openNewBrowserWindow();
const tab = await addTab(url, {window: win});
win.gBrowser.selectedTab = tab;
const hud = await openConsole(tab);
return {win, hud};
}
function getStorageErrorUrl(category) {
const BASE_STORAGE_ERROR_URL = "https://developer.mozilla.org/docs/Mozilla/Firefox/" +
"Privacy/Storage_access_policy/Errors/";

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

@ -1,194 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Load a page with tracking elements that get blocked and make sure that a
// 'learn more' link shows up in the webconsole.
"use strict";
requestLongerTimeout(2);
const TEST_FILE =
"browser/devtools/client/webconsole/test/mochitest/test-warning-groups.html";
const TEST_URI = "http://example.com/" + TEST_FILE;
const TRACKER_URL = "http://tracking.example.com/";
const IMG_FILE = "browser/devtools/client/webconsole/test/mochitest/test-image.png";
const TRACKER_IMG = "http://tracking.example.org/" + IMG_FILE;
const CONTENT_BLOCKING_GROUP_LABEL = "Content blocked messages";
const COOKIE_BEHAVIOR_PREF = "network.cookie.cookieBehavior";
const COOKIE_BEHAVIORS = {
// reject all third-party cookies
REJECT_FOREIGN: 1,
// reject all cookies
REJECT: 2,
// reject third-party cookies unless the eTLD already has at least one cookie
LIMIT_FOREIGN: 3,
// reject trackers
REJECT_TRACKER: 4,
};
const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
UrlClassifierTestUtils.addTestTrackers();
registerCleanupFunction(function() {
UrlClassifierTestUtils.cleanupTestTrackers();
});
pushPref("privacy.trackingprotection.enabled", true);
pushPref("devtools.webconsole.groupWarningMessages", true);
add_task(async function testContentBlockingMessage() {
const {hud, tab, win} = await openNewWindowAndConsole(
"http://tracking.example.org/" + TEST_FILE);
const now = Date.now();
info("Test content blocking message");
const message = `The resource at \u201chttp://tracking.example.com/?1&${now}\u201d ` +
`was blocked because content blocking is enabled`;
const onContentBlockingWarningMessage = waitForMessage(hud, message, ".warn");
emitContentBlockingMessage(tab, `${TRACKER_URL}?1&${now}`);
await onContentBlockingWarningMessage;
ok(true, "The content blocking message was displayed");
info("Emit a new content blocking message to check that it causes a grouping");
const onContentBlockingWarningGroupMessage =
waitForMessage(hud, CONTENT_BLOCKING_GROUP_LABEL, ".warn");
emitContentBlockingMessage(tab, `${TRACKER_URL}?2&${now}`);
const {node} = await onContentBlockingWarningGroupMessage;
is(node.querySelector(".warning-group-badge").textContent, "2",
"The badge has the expected text");
checkConsoleOutputForWarningGroup(hud, [
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL} 2`,
]);
info("Open the group");
node.querySelector(".arrow").click();
await waitFor(() => findMessage(hud, "http://tracking.example.com/?1"));
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL} 2`,
`| The resource at \u201chttp://tracking.example.com/?1&${now}\u201d was blocked`,
`| The resource at \u201chttp://tracking.example.com/?2&${now}\u201d was blocked`,
]);
await win.close();
});
add_task(async function testForeignCookieBlockedMessage() {
info("Test foreign cookie blocked message");
// We change the pref and open a new window to ensure it will be taken into account.
await pushPref(COOKIE_BEHAVIOR_PREF, COOKIE_BEHAVIORS.REJECT_FOREIGN);
const getWarningMsg = url => `Request to access cookie or storage on “${url}” was ` +
`blocked because we are blocking all third-party`;
await testStorageAccessBlockedGrouping(getWarningMsg);
});
add_task(async function testLimitForeignCookieBlockedMessage() {
info("Test unvisited eTLD foreign cookies blocked message");
// We change the pref and open a new window to ensure it will be taken into account.
await pushPref(COOKIE_BEHAVIOR_PREF, COOKIE_BEHAVIORS.LIMIT_FOREIGN);
const getWarningMsg = url => `Request to access cookie or storage on “${url}” was ` +
`blocked because we are blocking all third-party`;
await testStorageAccessBlockedGrouping(getWarningMsg);
});
add_task(async function testAllCookieBlockedMessage() {
info("Test all cookies blocked message");
// We change the pref and open a new window to ensure it will be taken into account.
await pushPref(COOKIE_BEHAVIOR_PREF, COOKIE_BEHAVIORS.REJECT);
const getWarningMsg = url => `Request to access cookie or storage on “${url}” was ` +
`blocked because we are blocking all storage access requests`;
await testStorageAccessBlockedGrouping(getWarningMsg);
});
add_task(async function testTrackerCookieBlockedMessage() {
info("Test tracker cookie blocked message");
// We change the pref and open a new window to ensure it will be taken into account.
await pushPref(COOKIE_BEHAVIOR_PREF, COOKIE_BEHAVIORS.REJECT_TRACKER);
const getWarningMsg = url => `Request to access cookie or storage on “${url}” was ` +
`blocked because it came from a tracker`;
await testStorageAccessBlockedGrouping(getWarningMsg);
});
add_task(async function testCookieBlockedByPermissionMessage() {
info("Test cookie blocked by permission message");
// Turn off tracking protection and add a block permission on the URL.
await pushPref("privacy.trackingprotection.enabled", false);
const p = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("http://tracking.example.org/");
Services.perms.addFromPrincipal(p, "cookie", Ci.nsIPermissionManager.DENY_ACTION);
const getWarningMsg = url => `Request to access cookies or storage on “${url}” was ` +
`blocked because of custom cookie permission`;
await testStorageAccessBlockedGrouping(getWarningMsg);
// Remove the custom permission.
Services.perms.removeFromPrincipal(p, "cookie");
});
/**
* Test that storage access blocked messages are grouped by emitting 2 messages.
*
* @param {Function} getWarningMessage: A function that takes an URL string as a parameter
* and returns the corresponding warning message.
*/
async function testStorageAccessBlockedGrouping(getWarningMessage) {
const {hud, win, tab} = await openNewWindowAndConsole(TEST_URI);
const now = Date.now();
hud.ui.clearOutput();
const onStorageAccessBlockedMessage =
waitForMessage(hud, getWarningMessage(`${TRACKER_IMG}?1&${now}`), ".warn");
emitStorageAccessBlockedMessage(tab, `${TRACKER_IMG}?1&${now}`);
await onStorageAccessBlockedMessage;
info("Emit a new content blocking message to check that it causes a grouping");
const onContentBlockingWarningGroupMessage =
waitForMessage(hud, CONTENT_BLOCKING_GROUP_LABEL, ".warn");
emitStorageAccessBlockedMessage(tab, `${TRACKER_IMG}?2&${now}`);
const {node} = await onContentBlockingWarningGroupMessage;
is(node.querySelector(".warning-group-badge").textContent, "2",
"The badge has the expected text");
checkConsoleOutputForWarningGroup(hud, [
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL} 2`,
]);
info("Open the group");
node.querySelector(".arrow").click();
await waitFor(() => findMessage(hud, TRACKER_IMG));
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL} 2`,
`| ${getWarningMessage(TRACKER_IMG + "?1&" + now)}`,
`| ${getWarningMessage(TRACKER_IMG + "?2&" + now)}`,
]);
hud.ui.clearOutput();
await win.close();
}
/**
* Emit a Content Blocking message. This is done by loading an iframe from an origin
* tagged as tracker. The image is loaded with a incremented counter query parameter
* each time so we can get the warning message.
*/
function emitContentBlockingMessage(tab, url) {
ContentTask.spawn(tab.linkedBrowser, url, function(innerURL) {
content.wrappedJSObject.loadIframe(innerURL);
});
}
/**
* Emit a Storage blocked message. This is done by loading an image from an origin
* tagged as tracker. The image is loaded with a incremented counter query parameter
* each time so we can get the warning message.
*/
function emitStorageAccessBlockedMessage(tab, url) {
ContentTask.spawn(tab.linkedBrowser, url, async function(innerURL) {
content.wrappedJSObject.loadImage(innerURL);
});
}

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

@ -1,241 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that warning messages can be grouped, per navigation and category, and that
// interacting with these groups works as expected.
"use strict";
requestLongerTimeout(2);
const TEST_FILE =
"browser/devtools/client/webconsole/test/mochitest/test-warning-groups.html";
const TEST_URI = "http://example.com/" + TEST_FILE;
const TRACKER_URL = "http://tracking.example.org/";
const BLOCKED_URL = TRACKER_URL +
"browser/devtools/client/webconsole/test/mochitest/test-image.png";
const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
registerCleanupFunction(function() {
UrlClassifierTestUtils.cleanupTestTrackers();
});
add_task(async function testContentBlockingMessage() {
const CONTENT_BLOCKING_GROUP_LABEL = "Content blocked messages";
// Tracking protection preferences
await UrlClassifierTestUtils.addTestTrackers();
await pushPref("privacy.trackingprotection.enabled", true);
// Enable groupWarning and persist log
await pushPref("devtools.webconsole.groupWarningMessages", true);
await pushPref("devtools.webconsole.persistlog", true);
const hud = await openNewTabAndConsole(TEST_URI);
info("Log a tracking protection message to check a single message isn't grouped");
let onContentBlockingWarningMessage = waitForMessage(hud, BLOCKED_URL, ".warn");
emitStorageAccessBlockedMessage(hud);
let {node} = await onContentBlockingWarningMessage;
is(node.querySelector(".warning-indent"), null, "The message has the expected style");
is(node.querySelector(".indent").getAttribute("data-indent"), "0",
"The message has the expected indent");
info("Log a simple message");
await logString(hud, "simple message 1");
info("Log a second tracking protection message to check that it causes the grouping");
let onContentBlockingWarningGroupMessage =
waitForMessage(hud, CONTENT_BLOCKING_GROUP_LABEL, ".warn");
emitStorageAccessBlockedMessage(hud);
({node} = await onContentBlockingWarningGroupMessage);
is(node.querySelector(".warning-group-badge").textContent, "2",
"The badge has the expected text");
checkConsoleOutputForWarningGroup(hud, [
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`simple message 1`,
]);
info("Log another simple message");
await logString(hud, "simple message 2");
checkConsoleOutputForWarningGroup(hud, [
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`simple message 1`,
`simple message 2`,
]);
info("Log a third tracking protection message to check that the badge updates");
emitStorageAccessBlockedMessage(hud);
await waitFor(() => node.querySelector(".warning-group-badge").textContent == "3");
checkConsoleOutputForWarningGroup(hud, [
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`simple message 1`,
`simple message 2`,
]);
info("Open the group");
node.querySelector(".arrow").click();
await waitFor(() => findMessage(hud, BLOCKED_URL));
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`simple message 1`,
`simple message 2`,
]);
info("Log a new tracking protection message to check it appears inside the group");
onContentBlockingWarningMessage =
waitForMessage(hud, BLOCKED_URL, ".warn");
emitStorageAccessBlockedMessage(hud);
await onContentBlockingWarningMessage;
ok(true, "The new tracking protection message is displayed");
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`| ${BLOCKED_URL}?4`,
`simple message 1`,
`simple message 2`,
]);
info("Reload the page and wait for it to be ready");
const onDomContentLoaded = BrowserTestUtils.waitForContentEvent(
hud.target.tab.linkedBrowser, "DOMContentLoaded", true);
ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
content.location.reload();
});
await onDomContentLoaded;
// Also wait for the navigation message to be displayed.
await waitFor(() => findMessage(hud, "Navigated to"));
info("Log a tracking protection message to check it is not grouped");
onContentBlockingWarningMessage =
waitForMessage(hud, BLOCKED_URL, ".warn");
emitStorageAccessBlockedMessage(hud);
await onContentBlockingWarningMessage;
await logString(hud, "simple message 3");
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`| ${BLOCKED_URL}?4`,
`simple message 1`,
`simple message 2`,
"Navigated to",
`${BLOCKED_URL}?5`,
`simple message 3`,
]);
info("Log a second tracking protection message to check that it causes the grouping");
onContentBlockingWarningGroupMessage =
waitForMessage(hud, CONTENT_BLOCKING_GROUP_LABEL, ".warn");
emitStorageAccessBlockedMessage(hud);
({node} = await onContentBlockingWarningGroupMessage);
is(node.querySelector(".warning-group-badge").textContent, "2",
"The badge has the expected text");
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`| ${BLOCKED_URL}?4`,
`simple message 1`,
`simple message 2`,
`Navigated to`,
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`simple message 3`,
]);
info("Check that opening this group works");
node.querySelector(".arrow").click();
await waitFor(() => findMessages(hud, BLOCKED_URL).length === 6);
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`| ${BLOCKED_URL}?4`,
`simple message 1`,
`simple message 2`,
`Navigated to`,
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?5`,
`| ${BLOCKED_URL}?6`,
`simple message 3`,
]);
info("Check that closing this group works, and let the other one open");
node.querySelector(".arrow").click();
await waitFor(() => findMessages(hud, BLOCKED_URL).length === 4);
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`| ${BLOCKED_URL}?4`,
`simple message 1`,
`simple message 2`,
`Navigated to`,
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`simple message 3`,
]);
info("Log a third tracking protection message to check that the badge updates");
emitStorageAccessBlockedMessage(hud);
await waitFor(() => node.querySelector(".warning-group-badge").textContent == "3");
checkConsoleOutputForWarningGroup(hud, [
`▼︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`| ${BLOCKED_URL}?1`,
`| ${BLOCKED_URL}?2`,
`| ${BLOCKED_URL}?3`,
`| ${BLOCKED_URL}?4`,
`simple message 1`,
`simple message 2`,
`Navigated to`,
`▶︎ ${CONTENT_BLOCKING_GROUP_LABEL}`,
`simple message 3`,
]);
});
let cpt = 0;
/**
* Emit a Content Blocking message. This is done by loading an image from an origin
* tagged as tracker. The image is loaded with a incremented counter query parameter
* each time so we can get the warning message.
*/
function emitStorageAccessBlockedMessage() {
const url = `${BLOCKED_URL}?${++cpt}`;
ContentTask.spawn(gBrowser.selectedBrowser, url, function(innerURL) {
content.wrappedJSObject.loadImage(innerURL);
});
}
/**
* Log a string from the content page.
*
* @param {WebConsole} hud
* @param {String} str
*/
function logString(hud, str) {
const onMessage = waitForMessage(hud, str);
ContentTask.spawn(gBrowser.selectedBrowser, str, function(arg) {
content.console.log(arg);
});
return onMessage;
}

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

@ -86,23 +86,6 @@ async function openNewTabAndConsole(url, clearJstermHistory = true) {
return hud;
}
/**
* Open a new window with a tab,open the toolbox, and select the webconsole.
*
* @param string url
* The URL for the tab to be opened.
* @return Promise<{win, hud, tab}>
* Resolves when the tab has been added, loaded and the toolbox has been opened.
* Resolves to the toolbox.
*/
async function openNewWindowAndConsole(url) {
const win = await openNewBrowserWindow();
const tab = await addTab(url, {window: win});
win.gBrowser.selectedTab = tab;
const hud = await openConsole(tab);
return {win, hud, tab};
}
/**
* Subscribe to the store and log out stringinfied versions of messages.
* This is a helper function for debugging, to make is easier to see what
@ -1238,43 +1221,3 @@ function isScrolledToBottom(container) {
return container.scrollTop + container.clientHeight >=
container.scrollHeight - lastNodeHeight / 2;
}
/**
*
* @param {WebConsole} hud
* @param {Array<String>} expectedMessages: An array of string representing the messages
* from the output. This can only be a part of the string of the
* message.
* Start the string with "▶︎ " or "▼ " to indicate that the
* message is a warningGroup (with respectively an open or
* collapsed arrow).
* Start the string with "| " to indicate that the message is
* inside a group and should be indented.
*/
function checkConsoleOutputForWarningGroup(hud, expectedMessages) {
const messages = findMessages(hud, "");
is(messages.length, expectedMessages.length, "Got the expected number of messages");
expectedMessages.forEach((expectedMessage, i) => {
const message = messages[i];
if (expectedMessage.startsWith("▶︎")) {
is(message.querySelector(".arrow").getAttribute("aria-expanded"), "false",
"There's a collapsed arrow");
expectedMessage = expectedMessage.replace("▶︎ ", "");
}
if (expectedMessage.startsWith("▼")) {
is(message.querySelector(".arrow").getAttribute("aria-expanded"), "true",
"There's an expanded arrow");
expectedMessage = expectedMessage.replace("▼︎ ", "");
}
if (expectedMessage.startsWith("|")) {
is(message.querySelector(".indent.warning-indent").getAttribute("data-indent"), "1",
"The message has the expected indent");
expectedMessage = expectedMessage.replace("| ", "");
}
ok(message.textContent.trim().includes(expectedMessage.trim()), `Message includes ` +
`the expected "${expectedMessage}" content - "${message.textContent.trim()}"`);
});
}

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

@ -1,28 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Warning groups webconsole test page</title>
</head>
<body>
<p>Warning groups webconsole test page</p>
<script>
"use strict";
/* exported loadImage, loadIframe */
function loadImage(src) {
const img = document.createElement("img");
img.src = src;
img.alt = (new URL(src)).search;
img.title = src;
document.body.appendChild(img);
}
function loadIframe(src) {
const iframe = document.createElement("iframe");
iframe.src = src;
document.body.appendChild(iframe);
}
</script>
</body>
</html>

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

@ -29,14 +29,12 @@ exports.ConsoleCommand = function(props) {
exports.ConsoleMessage = function(props) {
return Object.assign({
id: null,
innerWindowID: null,
allowRepeating: true,
source: null,
timeStamp: null,
type: null,
helperType: null,
level: null,
category: null,
messageText: null,
parameters: null,
repeatId: null,

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

@ -245,11 +245,9 @@ function transformPageErrorPacket(packet) {
const messageSource = matchesCSS ? MESSAGE_SOURCE.CSS
: MESSAGE_SOURCE.JAVASCRIPT;
return new ConsoleMessage({
innerWindowID: pageError.innerWindowID,
source: messageSource,
type: MESSAGE_TYPE.LOG,
level,
category: pageError.category,
messageText: pageError.errorMessage,
stacktrace: pageError.stacktrace ? pageError.stacktrace : null,
frame,
@ -430,79 +428,10 @@ function isPacketPrivate(packet) {
);
}
function createWarningGroupMessage(id, type, firstMessage) {
let messageText;
if (type === MESSAGE_TYPE.CONTENT_BLOCKING_GROUP) {
messageText = l10n.getStr("webconsole.group.contentBlocked");
}
return new ConsoleMessage({
id,
level: MESSAGE_LEVEL.WARN,
source: MESSAGE_SOURCE.CONSOLE_FRONTEND,
type,
messageText,
timeStamp: firstMessage.timeStamp,
innerWindowID: firstMessage.innerWindowID,
});
}
/**
* Get the warningGroup type in which the message could be in.
* @param {ConsoleMessage} message
* @returns {String|null} null if the message can't be part of a warningGroup.
*/
function getWarningGroupType(message) {
if (isContentBlockingMessage(message)) {
return MESSAGE_TYPE.CONTENT_BLOCKING_GROUP;
}
return null;
}
/**
* Returns a computed id given a message
*
* @param {ConsoleMessage} type: the message type, from MESSAGE_TYPE.
* @param {Integer} innerWindowID: the message innerWindowID.
* @returns {String}
*/
function getParentWarningGroupMessageId(message) {
return `${message.type}-${message.innerWindowID}`;
}
/**
* Returns true if the message is a warningGroup message (i.e. the "Header").
* @param {ConsoleMessage} message
* @returns {Boolean}
*/
function isWarningGroup(message) {
return message.type === MESSAGE_TYPE.CONTENT_BLOCKING_GROUP
|| message.type === MESSAGE_TYPE.CORS_GROUP
|| message.type === MESSAGE_TYPE.CSP_GROUP;
}
/**
* Returns true if the message is a content blocking message.
* @param {ConsoleMessage} message
* @returns {Boolean}
*/
function isContentBlockingMessage(message) {
const {category} = message;
return category == "cookieBlockedPermission" ||
category == "cookieBlockedTracker" ||
category == "cookieBlockedAll" ||
category == "cookieBlockedForeign" ||
category == "Tracking Protection";
}
module.exports = {
createWarningGroupMessage,
getInitialMessageCountForViewport,
getParentWarningGroupMessageId,
getWarningGroupType,
isContentBlockingMessage,
isGroupType,
isPacketPrivate,
isWarningGroup,
l10n,
prepareMessage,
// Export for use in testing.

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

@ -1519,7 +1519,6 @@ WebConsoleActor.prototype =
lineNumber: pageError.lineNumber,
columnNumber: pageError.columnNumber,
category: pageError.category,
innerWindowID: pageError.innerWindowID,
timeStamp: pageError.timeStamp,
warning: !!(pageError.flags & pageError.warningFlag),
error: !!(pageError.flags & pageError.errorFlag),
@ -1718,7 +1717,6 @@ WebConsoleActor.prototype =
});
result.category = message.category || "webdev";
result.innerWindowID = message.innerID;
return result;
},