Bug 1710284 - Copying CSS Rules manually from the Devtools Inspector inserts extra indentation r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D130549
This commit is contained in:
Clinton 2021-11-10 20:15:45 +00:00
parent c6510e2e9e
commit 1882c3b3e7
2 changed files with 14 additions and 10 deletions

View File

@ -22,6 +22,7 @@ const {
} = require("devtools/client/inspector/shared/utils");
const { debounce } = require("devtools/shared/debounce");
const EventEmitter = require("devtools/shared/event-emitter");
const DOUBLESPACE = " ";
loader.lazyRequireGetter(
this,
@ -625,6 +626,9 @@ CssRuleView.prototype = {
// Remove any double newlines.
text = text.replace(/(\r?\n)\r?\n/g, "$1");
// Replace 4 space indentation with 2 Spaces.
text = text.replace(/\ {4}/g, DOUBLESPACE);
}
clipboardHelper.copyString(text);

View File

@ -61,13 +61,13 @@ async function checkCopySelection(view) {
info("Checking that _Copy() returns the correct clipboard value");
const expectedPattern =
" margin: 10em;[\\r\\n]+" +
" font-size: 14pt;[\\r\\n]+" +
" font-family: helvetica, sans-serif;[\\r\\n]+" +
" color: #AAA;[\\r\\n]+" +
" margin: 10em;[\\r\\n]+" +
" font-size: 14pt;[\\r\\n]+" +
" font-family: helvetica, sans-serif;[\\r\\n]+" +
" color: #AAA;[\\r\\n]+" +
"}[\\r\\n]+" +
"html {[\\r\\n]+" +
" color: #000000;[\\r\\n]*";
" color: #000000;[\\r\\n]*";
const allMenuItems = openStyleContextMenuAndGetAllItems(view, prop);
const menuitemCopy = allMenuItems.find(
@ -119,13 +119,13 @@ async function checkSelectAll(view) {
view.contextMenu._onSelectAll();
const expectedPattern =
"element {[\\r\\n]+" +
" margin: 10em;[\\r\\n]+" +
" font-size: 14pt;[\\r\\n]+" +
" font-family: helvetica, sans-serif;[\\r\\n]+" +
" color: #AAA;[\\r\\n]+" +
" margin: 10em;[\\r\\n]+" +
" font-size: 14pt;[\\r\\n]+" +
" font-family: helvetica, sans-serif;[\\r\\n]+" +
" color: #AAA;[\\r\\n]+" +
"}[\\r\\n]+" +
"html {[\\r\\n]+" +
" color: #000000;[\\r\\n]+" +
" color: #000000;[\\r\\n]+" +
"}[\\r\\n]*";
const allMenuItems = openStyleContextMenuAndGetAllItems(view, prop);