Bug 929766 - Remove Orion from the SourceEditor component. r=msucan
|
@ -1227,14 +1227,6 @@ pref("devtools.hud.loglimit.console", 200);
|
|||
pref("devtools.editor.tabsize", 4);
|
||||
pref("devtools.editor.expandtab", true);
|
||||
|
||||
// Tells which component you want to use for source editing in developer tools.
|
||||
//
|
||||
// Available components:
|
||||
// "orion" - this is the Orion source code editor from the Eclipse project. It
|
||||
// provides programmer-specific editor features such as syntax highlighting,
|
||||
// indenting and bracket recognition.
|
||||
pref("devtools.editor.component", "orion");
|
||||
|
||||
// Enable the Font Inspector
|
||||
pref("devtools.fontinspector.enabled", true);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ browser.jar:
|
|||
content/browser/devtools/fontinspector/font-inspector.js (fontinspector/font-inspector.js)
|
||||
content/browser/devtools/fontinspector/font-inspector.xhtml (fontinspector/font-inspector.xhtml)
|
||||
content/browser/devtools/fontinspector/font-inspector.css (fontinspector/font-inspector.css)
|
||||
content/browser/devtools/orion.js (sourceeditor/orion/orion.js)
|
||||
content/browser/devtools/codemirror/codemirror.js (sourceeditor/codemirror/codemirror.js)
|
||||
content/browser/devtools/codemirror/codemirror.css (sourceeditor/codemirror/codemirror.css)
|
||||
content/browser/devtools/codemirror/javascript.js (sourceeditor/codemirror/javascript.js)
|
||||
|
@ -45,7 +44,6 @@ browser.jar:
|
|||
content/browser/devtools/codemirror/dialog.js (sourceeditor/codemirror/dialog/dialog.js)
|
||||
content/browser/devtools/codemirror/dialog.css (sourceeditor/codemirror/dialog/dialog.css)
|
||||
content/browser/devtools/codemirror/mozilla.css (sourceeditor/codemirror/mozilla.css)
|
||||
* content/browser/devtools/source-editor-overlay.xul (sourceeditor/source-editor-overlay.xul)
|
||||
content/browser/devtools/debugger.xul (debugger/debugger.xul)
|
||||
content/browser/devtools/debugger.css (debugger/debugger.css)
|
||||
content/browser/devtools/debugger-controller.js (debugger/debugger-controller.js)
|
||||
|
|
|
@ -1516,7 +1516,7 @@ var Scratchpad = {
|
|||
* Add an observer for Scratchpad events.
|
||||
*
|
||||
* The observer implements IScratchpadObserver := {
|
||||
* onReady: Called when the Scratchpad and its SourceEditor are ready.
|
||||
* onReady: Called when the Scratchpad and its Editor are ready.
|
||||
* Arguments: (Scratchpad aScratchpad)
|
||||
* }
|
||||
*
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -18,21 +18,21 @@
|
|||
}
|
||||
|
||||
.error {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-error.png");
|
||||
background-image: url("chrome://browser/skin/devtools/editor-error.png");
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.breakpoint {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
background-image: url("chrome://browser/skin/devtools/editor-breakpoint.png");
|
||||
}
|
||||
|
||||
.debugLocation {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
|
||||
background-image: url("chrome://browser/skin/devtools/editor-debug-location.png");
|
||||
}
|
||||
|
||||
.breakpoint.debugLocation {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
background-image: url("chrome://browser/skin/devtools/editor-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/editor-breakpoint.png");
|
||||
}
|
||||
|
||||
.error-line {
|
||||
|
|
|
@ -83,7 +83,7 @@ const CM_MAPPING = [
|
|||
|
||||
const CM_JUMP_DIALOG = [
|
||||
L10N.GetStringFromName("gotoLineCmd.promptTitle")
|
||||
+ " <input type=text style='width: 10em'/>"
|
||||
+ " <input class=jumptoline type=text style='width: 10em'/>"
|
||||
];
|
||||
|
||||
const { cssProperties, cssValues, cssColors } = getCSSKeywords();
|
||||
|
@ -193,7 +193,7 @@ Editor.prototype = {
|
|||
appendTo: function (el) {
|
||||
let def = promise.defer();
|
||||
let cm = editors.get(this);
|
||||
let env = el.ownerDocument.createElement("iframe");
|
||||
let env = el.ownerDocument.createElementNS(XUL_NS, "iframe");
|
||||
env.flex = 1;
|
||||
|
||||
if (cm)
|
||||
|
@ -505,7 +505,7 @@ Editor.prototype = {
|
|||
if (!info)
|
||||
return false;
|
||||
|
||||
return info.wrapClass == className;
|
||||
return ~info.wrapClass.split(" ").indexOf(className);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,9 +10,6 @@ JS_MODULES_PATH = 'modules/devtools/sourceeditor'
|
|||
|
||||
EXTRA_JS_MODULES += [
|
||||
'debugger.js',
|
||||
'editor.js',
|
||||
'source-editor-orion.jsm',
|
||||
'source-editor-ui.jsm',
|
||||
'source-editor.jsm',
|
||||
'editor.js'
|
||||
]
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
Eclipse Distribution License - v 1.0
|
||||
|
||||
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
* Neither the name of the Eclipse Foundation, Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
/* vim:set ts=2 sw=2 sts=2 et 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/. */
|
||||
|
||||
var copy = require('dryice').copy;
|
||||
|
||||
const ORION_EDITOR = "org.eclipse.orion.client.editor/web";
|
||||
|
||||
var js_src = copy.createDataObject();
|
||||
|
||||
copy({
|
||||
source: [
|
||||
ORION_EDITOR + "/orion/textview/global.js",
|
||||
ORION_EDITOR + "/orion/textview/eventTarget.js",
|
||||
ORION_EDITOR + "/orion/editor/regex.js",
|
||||
ORION_EDITOR + "/orion/textview/keyBinding.js",
|
||||
ORION_EDITOR + "/orion/textview/annotations.js",
|
||||
ORION_EDITOR + "/orion/textview/rulers.js",
|
||||
ORION_EDITOR + "/orion/textview/undoStack.js",
|
||||
ORION_EDITOR + "/orion/textview/textModel.js",
|
||||
ORION_EDITOR + "/orion/textview/projectionTextModel.js",
|
||||
ORION_EDITOR + "/orion/textview/tooltip.js",
|
||||
ORION_EDITOR + "/orion/textview/textView.js",
|
||||
ORION_EDITOR + "/orion/textview/textDND.js",
|
||||
ORION_EDITOR + "/orion/editor/htmlGrammar.js",
|
||||
ORION_EDITOR + "/orion/editor/textMateStyler.js",
|
||||
ORION_EDITOR + "/examples/textview/textStyler.js",
|
||||
],
|
||||
dest: js_src,
|
||||
});
|
||||
|
||||
copy({
|
||||
source: js_src,
|
||||
dest: "orion.js",
|
||||
});
|
||||
|
||||
var css_src = copy.createDataObject();
|
||||
|
||||
copy({
|
||||
source: [
|
||||
ORION_EDITOR + "/orion/textview/textview.css",
|
||||
ORION_EDITOR + "/orion/textview/rulers.css",
|
||||
ORION_EDITOR + "/orion/textview/annotations.css",
|
||||
ORION_EDITOR + "/examples/textview/textstyler.css",
|
||||
ORION_EDITOR + "/examples/editor/htmlStyles.css",
|
||||
],
|
||||
dest: css_src,
|
||||
});
|
||||
|
||||
copy({
|
||||
source: css_src,
|
||||
dest: "orion.css",
|
||||
});
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# Introduction
|
||||
|
||||
This is the Orion editor packaged for Mozilla.
|
||||
|
||||
The Orion editor web site: http://www.eclipse.org/orion
|
||||
|
||||
# Upgrade
|
||||
|
||||
To upgrade Orion to a newer version see the UPGRADE file.
|
||||
|
||||
Orion version: git clone from 2012-01-26
|
||||
commit hash 1d1150131dacecc9f4d9eb3cdda9103ea1819045
|
||||
|
||||
+ patch for Eclipse Bug 370584 - [Firefox] Edit menu items in context menus
|
||||
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=137d5a8e9bbc0fa204caae74ebd25a7d9d4729bd
|
||||
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=370584
|
||||
|
||||
+ patches for Eclipse Bug 370606 - Problems with UndoStack and deletions at
|
||||
the beginning of the document
|
||||
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=cec71bddaf32251c34d3728df5da13c130d14f33
|
||||
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=3ce24b94f1d8103b16b9cf16f2f50a6302d43b18
|
||||
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=27177e9a3dc70c20b4877e3eab3adfff1d56e342
|
||||
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=370606
|
||||
|
||||
+ patch for Mozilla Bug 730532 - remove CSS2Properties aliases for MozOpacity
|
||||
and MozOutline*
|
||||
see https://bugzilla.mozilla.org/show_bug.cgi?id=730532#c3
|
||||
|
||||
# License
|
||||
|
||||
The following files are licensed according to the contents in the LICENSE
|
||||
file:
|
||||
orion.js
|
||||
orion.css
|
||||
|
||||
# Theming
|
||||
|
||||
The syntax highlighting and the editor UI are themed using a style sheet. The
|
||||
default theme file is browser/themes/*/devtools/orion.css - this is based on the
|
||||
orion.css found in this folder.
|
||||
|
||||
Please note that the orion.css file from this folder is not used. It is kept
|
||||
here only as reference.
|
|
@ -1,20 +0,0 @@
|
|||
Upgrade notes:
|
||||
|
||||
1. Get the Orion client source code from:
|
||||
http://www.eclipse.org/orion
|
||||
|
||||
2. Install Dryice from:
|
||||
https://github.com/mozilla/dryice
|
||||
|
||||
You also need nodejs for Dryice to run:
|
||||
http://nodejs.org
|
||||
|
||||
3. Copy Makefile.dryice.js to:
|
||||
org.eclipse.orion.client/bundles/
|
||||
|
||||
4. Execute Makefile.dryice.js. You should get orion.js and orion.css.
|
||||
|
||||
5. Copy the two files back here.
|
||||
|
||||
6. Make a new build of Firefox.
|
||||
|
|
@ -1,277 +0,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/. */
|
||||
|
||||
.view {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.viewContainer {
|
||||
background-color: #eeeeee;
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
}
|
||||
::-webkit-scrollbar-corner {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.viewContent {
|
||||
}/* Styles for rulers */
|
||||
.ruler {
|
||||
background-color: white;
|
||||
}
|
||||
.ruler.annotations {
|
||||
border-right: 1px solid lightgray;
|
||||
width: 16px;
|
||||
}
|
||||
.ruler.folding {
|
||||
border-right: 1px solid lightgray;
|
||||
width: 14px;
|
||||
}
|
||||
.ruler.lines {
|
||||
border-right: 1px solid lightgray;
|
||||
text-align: right;
|
||||
}
|
||||
.ruler.overview {
|
||||
border-left: 1px solid lightgray;
|
||||
width: 14px;
|
||||
}
|
||||
|
||||
/* Styles for the line number ruler */
|
||||
.rulerLines {
|
||||
}
|
||||
.rulerLines.even
|
||||
.rulerLines.odd {
|
||||
}/* Styles for the annotation ruler (all lines) */
|
||||
.annotation {
|
||||
}
|
||||
.annotation.error,
|
||||
.annotation.warning
|
||||
.annotation.task,
|
||||
.annotation.bookmark,
|
||||
.annotation.breakpoint,
|
||||
.annotation.collapsed
|
||||
.annotation.expanded {
|
||||
}
|
||||
|
||||
/* Styles for the annotation ruler (first line) */
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotationHTML.error {
|
||||
/* images/error.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAPVvcvWHiPVucvRuc+ttcfV6f91KVN5LU99PV/FZY/JhaM4oN84pONE4Rd1ATfJLWutVYPRgbdxpcsgWKMgZKs4lNfE/UvE/U+artcpdSc5uXveimslHPuBhW/eJhfV5efaCgO2CgP+/v+PExP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACUALAAAAAAQABAAAAZ+wJJwSCwaScgkySgkjTQZTkYzWhadnE5oE+pwqkSshwQqkzxfa4kkQXxEpA9J9EFI1KQGQQBAigYCBA14ExEWF0gXihETeA0QD3AkD5QQg0NsDnAJmwkOd5gYFSQKpXAFDBhqaxgLBwQBBAapq00YEg0UDRKqTGtKSL7Cw8JBADs=");
|
||||
}
|
||||
.annotationHTML.warning {
|
||||
/* images/warning.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAP7bc//egf/ij/7ijv/jl/7kl//mnv7lnv/uwf7CTP7DTf7DT/7IW//Na/7Na//NbP7QdP/dmbltAIJNAF03AMSAJMSCLKqASa2DS6uBSquCSrGHTq6ETbCHT7WKUrKIUcCVXL+UXMOYX8GWXsSZYMiib6+ETbOIUcOXX86uhd3Muf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACsALAAAAAAQABAAAAZowJVwSCwaj0ihikRSJYcoBEL0XKlGkcjImQQhJBREKFnyICoThKeE/AAW6AXgdPyUAgrLJBEo0YsbAQyDhAEdRRwDDw8OaA4NDQImRBgFEJdglxAEGEQZKQcHBqOkKRpFF6mqq1WtrUEAOw==");
|
||||
}
|
||||
.annotationHTML.task {
|
||||
/* images/task.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAAN7s4uTy6ICvY423c2WdP2ugR3mqWYeza2ejOl6VNVqPM1aJMURsJ2GaOnKlT8PbsbPDqGmmO1OCLk98LEhxKGWfOWKaN0t2KkJoJf///////wAAAAAAAAAAAAAAAAAAACH5BAEAABoALAAAAAAQABAAAAVmoCaOZDk+UaquDxkNcCxHJHLceI6QleD/vkCmQrIYjkiDMGAhJRzQ6NKRICkKgYJ2qVWQFktCmEBYkCSNZSbQaDckpAl5TCZMSBdtAaDXX0gUUYJRFCQMSYgGDCQQGI6PkBAmkyUhADs=");
|
||||
}
|
||||
.annotationHTML.bookmark {
|
||||
/* images/bookmark.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQALMAAP7//+/VNPzZS/vifeumAPrBOOSlHOSuRP///wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAgALAAAAAAQABAAAARLEMlJq5Xn3EvIrkenfRIhCB5pmKhRdbAJAGhssuc8n6eJoAKdkOaTAIdEQeWoA1oGsiZhYAnIcqiApVPjElyUbkFSgCkn5XElLYkAADs=");
|
||||
}
|
||||
.annotationHTML.breakpoint {
|
||||
/* images/breakpoint.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAFheoFxkoFxnpmt0pmZxpnF7rYyWwmJwpnaFs3aDrWt8rXGBrYycwmZ3mXuNs42cu77F03GIs3aJrYGVu2J5oKCuxeDj6LK/03GLrYieu3aIoIygu6m4zcLN3MTM1m6Rs2aLriRgkSZilXGXtoGcs7LD0QBLhSZikihol3ScubrO2Yaqu5q4xpO0wpm7yabF0ZO9yaXI0r3X3tHj6P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADQALAAAAAAQABAAAAafQJpwSCwWLYZBIDAwWIw0A+FFpW6aRUPCxe1yE4ahhdCCxWSzmSwGgxGeUceKpUqhUCkVa7UK0wgkJCUjJoUmIyWBBEIEGhoeJ4YmJx6OAUIADQ0QIZIhEJoAQgEUFBUgkiAVpZdRCxIPFx8iIh8XDw4FfhYHDhgZHB0dHBkYEwdwUQoTEc3OEwp+QwYHCBMMDBMIB9JESAJLAk5Q5EVBADs=");
|
||||
}
|
||||
.annotationHTML.collapsed {
|
||||
/* images/collapsed.png */
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWBJREFUeNpi/P//PwMlgImBQkCxASzoAp++fo+6de+Z+fXbD/Jev/nAICoiwKCpqrBBTUlqNR835zJ09YzIYfDxy7eo/cevLmXlYGNQUJAEahZieP3mHcODB08Zfv/4w+BoqR3Nz8O1DKcXzt94HPqXmZlBU1+LgZNfkMHazIOBA0hr6uswgMTP33gYijcMLlx/EMAnLs7w7sc/hg9AG0HgPZB+B8S84hJA+UcBeMPg+at3DJIMnAxZzt5wsUhnXzDdsmIVWB6vAcLCfAys3z4wzN64huEfkJ/uH8IwexOQDQymD2/fgeXxekFLRWHD51evGDhZGRi4WSFSnCwgNjB2Xr1m0AbK4zXAQkdhNdPf3wx3r91g+PruLcOqnasYvn54x3Dv2k0G5r+/GMyB8nijEQTefvoadeH6w9Cbtx8GvH//kUFQkJ9BQ1V+g76m/GphPu5lBA0YenmBYgMAAgwA34GIKjmLxOUAAAAASUVORK5CYII=");
|
||||
}
|
||||
.annotationHTML.expanded {
|
||||
/* images/expanded.png */
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAT5JREFUeNrUksFKw0AURW+mTWw67SSEiG209U90r4jddFO34l+5U0HdZCHiFwiCOz9AlMSmGEpMOqk1TWJSFGyFbATR2dyZd+Dw3mOENE3xkyP8PYHrBT3OX7uW43ZefA6FUaw1dJPSyrmu1k8KBYOh37Od4XFZLEPXFdRrFMGIw3U9TKMYqw1tb0VjcxLy9eEF425CCIxWE5JcxSQGxCyNloG87gXhwWIHc4J767lTZQw8ShFGSZbxRyaQmZJxd3NRUJ6ffwQNEi6PzG/L2tjdmvFCgcKqKL2F2Olu43MzggDka+IjPuOFI7Sbujn2fUglYKkkzFIi+R0I/QDrGS8UqDX5QkhiOHYfE84hkhSTkGNgOyDJFCzjhYLTq+vDtrG8r1LZtB6fcHtzB+uhD5VWzLx+lvF/8JV/XfAuwADsrJbMGG4l4AAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.annotationHTML.multiple {
|
||||
/* images/multiple.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAOdpa+yJiuFYXOFYXeBYXONwded8f+NwdmhwkHB4iPr7/ezx+fP2+2h4kOzy+Wh4iPr8/gCBwTaczjaXyjaYyjaXyTaYyfr8/QCMzQCMzACHxzao2jal2Dak1zag03iAgI/Ckn64fZrHmX+4fZLCianPopPCiarOoqbLlafLlbnXq7nWq6fLlMTcsoCIeJCQcIiIeKCYaJiQcO16ee16evGVlfGWlfahn/ahoPWhn/WhoPe1tP///////wAAAAAAACH5BAEAAD0ALAAAAAAQABAAAAaRwJ5wSCwaj8WYcslcDmObaDTGq1Zjzw4mk+FQIRcFTzaUeTRoj4zHaI+HL0lkLnnxFgsH7zWEWSoTFBMwVlUwQy6JMDCJjYwuQx8tk5MfOzk4OjcfkSssKCkqHzY0MzQ1nEIJJSYkJCcJAQCzAQlDDyIjISMiCQYEAgMGD0MNIMfHDQUHBc3EQgjR0tPSSNY9QQA7");
|
||||
}
|
||||
.annotationHTML.overlay {
|
||||
/* images/plus.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEAQvB2JVdrAAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAD1JREFUCNdtjkESADAEAzemf69f66HMqGlOIhYiFRFRtSQBWAY7mzx+EDTL6sSgb1jTk7Q87rxyqe37fXsAa78gLyZnRgEAAAAASUVORK5CYII=");
|
||||
background-position: right bottom;
|
||||
position: relative;
|
||||
top: -16px;
|
||||
}
|
||||
.annotationHTML.currentBracket {
|
||||
/* images/currentBracket.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLEBULCGQmEKAAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAnklEQVQ4y7VTsRHDIBATJg1HCUzAHEzFBExAzwZsRMkE9gifKhc72ODYibr/+xcnoQdugq0LAujEwmbn0UxQh4OxpjX1XgshwFqLnPM5PQTQGlprWpbl3RhJ/CSQUm7qPYLp7i8cEpRSoJT6ju0lIaVEQgiKMQ4lHHpQayVjzHWCn5jIOcc8z9dMBADvPZxz3SC1tzCI8vgWdvL+VzwB8JSj2GFTyxIAAAAASUVORK5CYII=");
|
||||
}
|
||||
.annotationHTML.matchingBracket {
|
||||
/* images/matchingBracket.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLEBUMAsuyb3kAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAoklEQVQ4y61TsQ3EIAw80DcI0USKGIApWIsB2IGGKbJPugxBR3VfvfRRCOSTvw7LPuPzGXgI8f0gwAsFu5rXIYMdDiEOIdnKW5YFzjnEGH+bhwA/KKVwmibu0BhRnpEZY1BrHTaVT7fQJZjnGeu63tOAJFNKVEox53yqQZfAWstt27oidgm01ve3UEqBaBjnspG89wgh3LiFgZXHt3Dh23/FGxKViehm0X85AAAAAElFTkSuQmCC");
|
||||
}
|
||||
.annotationHTML.currentLine {
|
||||
/* images/currentLine.gif */
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAALxe0bNWzbdZzrlb0KpPx61RybBTy6VLxadNxZGctIeUroyYsG92hHyMqIKRq2l9nmyAoHGDonaIpStXj6q80k1aXf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABYALAAAAAAQABAAAAVCoCWOZGmeKDql5ppOMGXBk/zOoltSNO6XrlXwxIPNYiMGq8SoLC2MaNPygEQkDYdikUg6LQcEoWAICAaA5HPNLoUAADs=");
|
||||
}
|
||||
|
||||
/* Styles for the overview ruler */
|
||||
.annotationOverview {
|
||||
cursor: pointer;
|
||||
border-radius: 2px;
|
||||
left: 2px;
|
||||
width: 8px;
|
||||
}
|
||||
.annotationOverview.task {
|
||||
background-color: lightgreen;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.breakpoint {
|
||||
background-color: lightblue;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
.annotationOverview.bookmark {
|
||||
background-color: yellow;
|
||||
border: 1px solid orange;
|
||||
}
|
||||
.annotationOverview.error {
|
||||
background-color: lightcoral;
|
||||
border: 1px solid darkred;
|
||||
}
|
||||
.annotationOverview.warning {
|
||||
background-color: Gold;
|
||||
border: 1px solid black;
|
||||
}
|
||||
.annotationOverview.currentBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
.annotationOverview.matchingBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
.annotationOverview.currentLine {
|
||||
background-color: #EAF2FE;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
/* Styles for text range */
|
||||
.annotationRange {
|
||||
background-repeat: repeat-x;
|
||||
background-position: left bottom;
|
||||
}
|
||||
.annotationRange.task {
|
||||
/* images/squiggly_task.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLDhEoIrb7JmcAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAGUlEQVQI12NggIH/DGdhDCM45z/DfyiBAADgdQjGhI/4DAAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.annotationRange.breakpoint {
|
||||
/* images/squiggly_breakpoint.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLDhEqHTKradgAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAIklEQVQI11XJMQ0AMAzAMGMafwrFlD19+sUKIJTFo9k+B/kQ+Qr2bIVKOgAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.annotationRange.bookmark {
|
||||
/* images/squiggly_bookmark.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
||||
}
|
||||
.annotationRange.error {
|
||||
/* images/squiggly_error.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.annotationRange.warning {
|
||||
/* images/squiggly_warning.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
||||
}
|
||||
.annotationRange.currentBracket {
|
||||
}
|
||||
.annotationRange.matchingBracket {
|
||||
outline: 1px solid red;
|
||||
}
|
||||
|
||||
/* Styles for lines of text */
|
||||
.annotationLine {
|
||||
}
|
||||
.annotationLine.currentLine {
|
||||
background-color: #EAF2FE;
|
||||
}
|
||||
|
||||
.token_singleline_comment {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.token_multiline_comment {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.token_doc_comment {
|
||||
color: #00008F;
|
||||
}
|
||||
|
||||
.token_doc_html_markup {
|
||||
color: #7F7F9F;
|
||||
}
|
||||
|
||||
.token_doc_tag {
|
||||
color: #7F9FBF;
|
||||
}
|
||||
|
||||
.token_task_tag {
|
||||
color: #7F9FBF;
|
||||
}
|
||||
|
||||
.token_string {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.token_keyword {
|
||||
color: darkred;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.token_space {
|
||||
/* images/white_space.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
.token_tab {
|
||||
/* images/white_tab.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
.line_caret {
|
||||
background-color: #EAF2FE;
|
||||
}
|
||||
|
||||
/* Styling for html syntax highlighting */
|
||||
.entity-name-tag {
|
||||
color: #3f7f7f;
|
||||
}
|
||||
|
||||
.entity-other-attribute-name {
|
||||
color: #7f007f;
|
||||
}
|
||||
|
||||
.punctuation-definition-comment {
|
||||
color: #3f5fbf;
|
||||
}
|
||||
|
||||
.comment {
|
||||
color: #3f5fbf
|
||||
}
|
||||
|
||||
.string-quoted {
|
||||
color: #2a00ff;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.invalid {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
<?xml version="1.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/. -->
|
||||
<!DOCTYPE overlay [
|
||||
<!ENTITY % editMenuStrings SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
|
||||
%editMenuStrings;
|
||||
<!ENTITY % sourceEditorStrings SYSTEM "chrome://browser/locale/devtools/sourceeditor.dtd">
|
||||
%sourceEditorStrings;
|
||||
]>
|
||||
<overlay id="sourceEditorOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<!-- This Source Editor overlay requires the editMenuOverlay.xul to be loaded.
|
||||
The globalOverlay.js script is also required in the XUL document where
|
||||
the source-editor-overlay.xul is loaded. Do not use #editMenuKeys to
|
||||
avoid conflicts! -->
|
||||
|
||||
<script type="application/javascript">
|
||||
function goUpdateSourceEditorMenuItems()
|
||||
{
|
||||
goUpdateGlobalEditMenuItems();
|
||||
let commands = ['se-cmd-undo', 'se-cmd-redo', 'se-cmd-cut', 'se-cmd-paste',
|
||||
'se-cmd-delete'];
|
||||
commands.forEach(goUpdateCommand);
|
||||
}
|
||||
</script>
|
||||
|
||||
<commandset id="sourceEditorCommands">
|
||||
<command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
|
||||
<command id="cmd_findAgain" oncommand="goDoCommand('cmd_findAgain')" disabled="true"/>
|
||||
<command id="cmd_findPrevious" oncommand="goDoCommand('cmd_findPrevious')" disabled="true"/>
|
||||
<command id="cmd_gotoLine" oncommand="goDoCommand('cmd_gotoLine')"/>
|
||||
<command id="se-cmd-selectAll" oncommand="goDoCommand('se-cmd-selectAll')"/>
|
||||
<command id="se-cmd-cut" oncommand="goDoCommand('se-cmd-cut')" disabled="true"/>
|
||||
<command id="se-cmd-paste" oncommand="goDoCommand('se-cmd-paste')" disabled="true"/>
|
||||
<command id="se-cmd-delete" oncommand="goDoCommand('se-cmd-delete')" disabled="true"/>
|
||||
<command id="se-cmd-undo" oncommand="goDoCommand('se-cmd-undo')" disabled="true"/>
|
||||
<command id="se-cmd-redo" oncommand="goDoCommand('se-cmd-redo')" disabled="true"/>
|
||||
</commandset>
|
||||
|
||||
<keyset id="sourceEditorKeys">
|
||||
<!-- Do not use both #sourceEditorKeys and #editMenuKeys in the same
|
||||
document to avoid conflicts! -->
|
||||
<key id="key_undo"
|
||||
key="&undoCmd.key;"
|
||||
modifiers="accel"
|
||||
command="se-cmd-undo"/>
|
||||
#ifdef XP_UNIX
|
||||
<key id="key_redo"
|
||||
key="&undoCmd.key;"
|
||||
modifiers="accel,shift"
|
||||
command="se-cmd-redo"/>
|
||||
#else
|
||||
<key id="key_redo"
|
||||
key="&redoCmd.key;"
|
||||
modifiers="accel"
|
||||
command="se-cmd-redo"/>
|
||||
#endif
|
||||
<key id="key_cut"
|
||||
key="&cutCmd.key;"
|
||||
modifiers="accel"
|
||||
command="se-cmd-cut"/>
|
||||
<key id="key_copy"
|
||||
key="©Cmd.key;"
|
||||
modifiers="accel"
|
||||
command="cmd_copy"/>
|
||||
<key id="key_paste"
|
||||
key="&pasteCmd.key;"
|
||||
modifiers="accel"
|
||||
command="se-cmd-paste"/>
|
||||
<key id="key_gotoLine"
|
||||
key="&gotoLineCmd.key;"
|
||||
command="cmd_gotoLine"
|
||||
modifiers="accel"/>
|
||||
<key id="key_delete"
|
||||
keycode="VK_DELETE"
|
||||
command="se-cmd-delete"/>
|
||||
<key id="key_selectAll"
|
||||
key="&selectAllCmd.key;"
|
||||
modifiers="accel"
|
||||
command="se-cmd-selectAll"/>
|
||||
<key id="key_find"
|
||||
key="&findCmd.key;"
|
||||
modifiers="accel"
|
||||
command="cmd_find"/>
|
||||
<key id="key_findAgain"
|
||||
key="&findAgainCmd.key;"
|
||||
modifiers="accel"
|
||||
command="cmd_findAgain"/>
|
||||
<key id="key_findPrevious"
|
||||
key="&findAgainCmd.key;"
|
||||
modifiers="shift,accel"
|
||||
command="cmd_findPrevious"/>
|
||||
<key id="key_findAgain2"
|
||||
keycode="&findAgainCmd.key2;"
|
||||
command="cmd_findAgain"/>
|
||||
<key id="key_findPrevious2"
|
||||
keycode="&findAgainCmd.key2;"
|
||||
modifiers="shift"
|
||||
command="cmd_findPrevious"/>
|
||||
</keyset>
|
||||
|
||||
<!-- Items for the Edit menu -->
|
||||
|
||||
<menuitem id="se-menu-undo"
|
||||
label="&undoCmd.label;"
|
||||
key="key_undo"
|
||||
accesskey="&undoCmd.accesskey;"
|
||||
command="se-cmd-undo"/>
|
||||
<menuitem id="se-menu-redo"
|
||||
label="&redoCmd.label;"
|
||||
key="key_redo"
|
||||
accesskey="&redoCmd.accesskey;"
|
||||
command="se-cmd-redo"/>
|
||||
<menuitem id="se-menu-cut"
|
||||
label="&cutCmd.label;"
|
||||
key="key_cut"
|
||||
accesskey="&cutCmd.accesskey;"
|
||||
command="se-cmd-cut"/>
|
||||
<menuitem id="se-menu-copy"
|
||||
label="©Cmd.label;"
|
||||
key="key_copy"
|
||||
accesskey="©Cmd.accesskey;"
|
||||
command="cmd_copy"/>
|
||||
<menuitem id="se-menu-paste"
|
||||
label="&pasteCmd.label;"
|
||||
key="key_paste"
|
||||
accesskey="&pasteCmd.accesskey;"
|
||||
command="se-cmd-paste"/>
|
||||
<menuitem id="se-menu-delete"
|
||||
label="&deleteCmd.label;"
|
||||
key="key_delete"
|
||||
accesskey="&deleteCmd.accesskey;"
|
||||
command="se-cmd-delete"/>
|
||||
<menuitem id="se-menu-selectAll"
|
||||
label="&selectAllCmd.label;"
|
||||
key="key_selectAll"
|
||||
accesskey="&selectAllCmd.accesskey;"
|
||||
command="se-cmd-selectAll"/>
|
||||
<menuitem id="se-menu-find"
|
||||
label="&findCmd.label;"
|
||||
accesskey="&findCmd.accesskey;"
|
||||
key="key_find"
|
||||
command="cmd_find"/>
|
||||
<menuitem id="se-menu-findAgain"
|
||||
label="&findAgainCmd.label;"
|
||||
accesskey="&findAgainCmd.accesskey;"
|
||||
key="key_findAgain"
|
||||
command="cmd_findAgain"/>
|
||||
<menuitem id="se-menu-gotoLine"
|
||||
label="&gotoLineCmd.label;"
|
||||
accesskey="&gotoLineCmd.accesskey;"
|
||||
key="key_gotoLine"
|
||||
command="cmd_gotoLine"/>
|
||||
|
||||
<!-- Items for context menus -->
|
||||
|
||||
<menuitem id="se-cMenu-undo"
|
||||
label="&undoCmd.label;"
|
||||
key="key_undo"
|
||||
accesskey="&undoCmd.accesskey;"
|
||||
command="se-cmd-undo"/>
|
||||
<menuitem id="se-cMenu-cut"
|
||||
label="&cutCmd.label;"
|
||||
key="key_cut"
|
||||
accesskey="&cutCmd.accesskey;"
|
||||
command="se-cmd-cut"/>
|
||||
<menuitem id="se-cMenu-copy"
|
||||
label="©Cmd.label;"
|
||||
key="key_copy"
|
||||
accesskey="©Cmd.accesskey;"
|
||||
command="cmd_copy"/>
|
||||
<menuitem id="se-cMenu-paste"
|
||||
label="&pasteCmd.label;"
|
||||
key="key_paste"
|
||||
accesskey="&pasteCmd.accesskey;"
|
||||
command="se-cmd-paste"/>
|
||||
<menuitem id="se-cMenu-delete"
|
||||
label="&deleteCmd.label;"
|
||||
key="key_delete"
|
||||
accesskey="&deleteCmd.accesskey;"
|
||||
command="se-cmd-delete"/>
|
||||
<menuitem id="se-cMenu-selectAll"
|
||||
label="&selectAllCmd.label;"
|
||||
key="key_selectAll"
|
||||
accesskey="&selectAllCmd.accesskey;"
|
||||
command="se-cmd-selectAll"/>
|
||||
<menuitem id="se-cMenu-find"
|
||||
label="&findCmd.label;"
|
||||
accesskey="&findCmd.accesskey;"
|
||||
key="key_find"
|
||||
command="cmd_find"/>
|
||||
<menuitem id="se-cMenu-findAgain"
|
||||
label="&findAgainCmd.label;"
|
||||
accesskey="&findAgainCmd.accesskey;"
|
||||
key="key_findAgain"
|
||||
command="cmd_findAgain"/>
|
||||
<menuitem id="se-cMenu-gotoLine"
|
||||
label="&gotoLineCmd.label;"
|
||||
accesskey="&gotoLineCmd.accesskey;"
|
||||
key="key_gotoLine"
|
||||
command="cmd_gotoLine"/>
|
||||
</overlay>
|
|
@ -1,332 +0,0 @@
|
|||
/* vim:set ts=2 sw=2 sts=2 et 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 Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["SourceEditorUI"];
|
||||
|
||||
/**
|
||||
* The Source Editor component user interface.
|
||||
*/
|
||||
this.SourceEditorUI = function SourceEditorUI(aEditor)
|
||||
{
|
||||
this.editor = aEditor;
|
||||
this._onDirtyChanged = this._onDirtyChanged.bind(this);
|
||||
}
|
||||
|
||||
SourceEditorUI.prototype = {
|
||||
/**
|
||||
* Initialize the user interface. This is called by the SourceEditor.init()
|
||||
* method.
|
||||
*/
|
||||
init: function SEU_init()
|
||||
{
|
||||
this._ownerWindow = this.editor.parentElement.ownerDocument.defaultView;
|
||||
},
|
||||
|
||||
/**
|
||||
* The UI onReady function is executed once the Source Editor completes
|
||||
* initialization and it is ready for usage. Currently this code sets up the
|
||||
* nsIController.
|
||||
*/
|
||||
onReady: function SEU_onReady()
|
||||
{
|
||||
if (this._ownerWindow.controllers) {
|
||||
this._controller = new SourceEditorController(this.editor);
|
||||
this._ownerWindow.controllers.insertControllerAt(0, this._controller);
|
||||
this.editor.addEventListener(this.editor.EVENTS.DIRTY_CHANGED,
|
||||
this._onDirtyChanged);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The "go to line" command UI. This displays a prompt that allows the user to
|
||||
* input the line number to jump to.
|
||||
*/
|
||||
gotoLine: function SEU_gotoLine()
|
||||
{
|
||||
let oldLine = this.editor.getCaretPosition ?
|
||||
this.editor.getCaretPosition().line : null;
|
||||
let newLine = {value: oldLine !== null ? oldLine + 1 : ""};
|
||||
|
||||
let result = Services.prompt.prompt(this._ownerWindow,
|
||||
SourceEditorUI.strings.GetStringFromName("gotoLineCmd.promptTitle"),
|
||||
SourceEditorUI.strings.GetStringFromName("gotoLineCmd.promptMessage"),
|
||||
newLine, null, {});
|
||||
|
||||
newLine.value = parseInt(newLine.value);
|
||||
if (result && !isNaN(newLine.value) && --newLine.value != oldLine) {
|
||||
if (this.editor.getLineCount) {
|
||||
let lines = this.editor.getLineCount() - 1;
|
||||
this.editor.setCaretPosition(Math.max(0, Math.min(lines, newLine.value)));
|
||||
} else {
|
||||
this.editor.setCaretPosition(Math.max(0, newLine.value));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* The "find" command UI. This displays a prompt that allows the user to input
|
||||
* the string to search for in the code. By default the current selection is
|
||||
* used as a search string, or the last search string.
|
||||
*/
|
||||
find: function SEU_find()
|
||||
{
|
||||
let str = {value: this.editor.getSelectedText()};
|
||||
if (!str.value && this.editor.lastFind) {
|
||||
str.value = this.editor.lastFind.str;
|
||||
}
|
||||
|
||||
let result = Services.prompt.prompt(this._ownerWindow,
|
||||
SourceEditorUI.strings.GetStringFromName("findCmd.promptTitle"),
|
||||
SourceEditorUI.strings.GetStringFromName("findCmd.promptMessage"),
|
||||
str, null, {});
|
||||
|
||||
if (result && str.value) {
|
||||
let start = this.editor.getSelection().end;
|
||||
let pos = this.editor.find(str.value, {ignoreCase: true, start: start});
|
||||
if (pos == -1) {
|
||||
this.editor.find(str.value, {ignoreCase: true});
|
||||
}
|
||||
this._onFind();
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the next occurrence of the last search string.
|
||||
*/
|
||||
findNext: function SEU_findNext()
|
||||
{
|
||||
let lastFind = this.editor.lastFind;
|
||||
if (lastFind) {
|
||||
this.editor.findNext(true);
|
||||
this._onFind();
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the previous occurrence of the last search string.
|
||||
*/
|
||||
findPrevious: function SEU_findPrevious()
|
||||
{
|
||||
let lastFind = this.editor.lastFind;
|
||||
if (lastFind) {
|
||||
this.editor.findPrevious(true);
|
||||
this._onFind();
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* This executed after each find/findNext/findPrevious operation.
|
||||
* @private
|
||||
*/
|
||||
_onFind: function SEU__onFind()
|
||||
{
|
||||
let lastFind = this.editor.lastFind;
|
||||
if (lastFind && lastFind.index > -1) {
|
||||
this.editor.setSelection(lastFind.index, lastFind.index + lastFind.str.length);
|
||||
}
|
||||
|
||||
if (this._ownerWindow.goUpdateCommand) {
|
||||
this._ownerWindow.goUpdateCommand("cmd_findAgain");
|
||||
this._ownerWindow.goUpdateCommand("cmd_findPrevious");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This is executed after each undo/redo operation.
|
||||
* @private
|
||||
*/
|
||||
_onUndoRedo: function SEU__onUndoRedo()
|
||||
{
|
||||
if (this._ownerWindow.goUpdateCommand) {
|
||||
this._ownerWindow.goUpdateCommand("se-cmd-undo");
|
||||
this._ownerWindow.goUpdateCommand("se-cmd-redo");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The DirtyChanged event handler for the editor. This tracks the editor state
|
||||
* changes to make sure the Source Editor overlay Undo/Redo commands are kept
|
||||
* up to date.
|
||||
* @private
|
||||
*/
|
||||
_onDirtyChanged: function SEU__onDirtyChanged()
|
||||
{
|
||||
this._onUndoRedo();
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the SourceEditorUI instance. This is called by the
|
||||
* SourceEditor.destroy() method.
|
||||
*/
|
||||
destroy: function SEU_destroy()
|
||||
{
|
||||
if (this._ownerWindow.controllers) {
|
||||
this.editor.removeEventListener(this.editor.EVENTS.DIRTY_CHANGED,
|
||||
this._onDirtyChanged);
|
||||
}
|
||||
|
||||
this._ownerWindow = null;
|
||||
this.editor = null;
|
||||
this._controller = null;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Source Editor nsIController implements features that need to be available
|
||||
* from XUL commands.
|
||||
*
|
||||
* @constructor
|
||||
* @param object aEditor
|
||||
* SourceEditor object instance for which the controller is instanced.
|
||||
*/
|
||||
function SourceEditorController(aEditor)
|
||||
{
|
||||
this._editor = aEditor;
|
||||
}
|
||||
|
||||
SourceEditorController.prototype = {
|
||||
/**
|
||||
* Check if a command is supported by the controller.
|
||||
*
|
||||
* @param string aCommand
|
||||
* The command name you want to check support for.
|
||||
* @return boolean
|
||||
* True if the command is supported, false otherwise.
|
||||
*/
|
||||
supportsCommand: function SEC_supportsCommand(aCommand)
|
||||
{
|
||||
let result;
|
||||
|
||||
switch (aCommand) {
|
||||
case "cmd_find":
|
||||
case "cmd_findAgain":
|
||||
case "cmd_findPrevious":
|
||||
case "cmd_gotoLine":
|
||||
case "se-cmd-undo":
|
||||
case "se-cmd-redo":
|
||||
case "se-cmd-cut":
|
||||
case "se-cmd-paste":
|
||||
case "se-cmd-delete":
|
||||
case "se-cmd-selectAll":
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if a command is enabled or not.
|
||||
*
|
||||
* @param string aCommand
|
||||
* The command name you want to check if it is enabled or not.
|
||||
* @return boolean
|
||||
* True if the command is enabled, false otherwise.
|
||||
*/
|
||||
isCommandEnabled: function SEC_isCommandEnabled(aCommand)
|
||||
{
|
||||
let result;
|
||||
|
||||
switch (aCommand) {
|
||||
case "cmd_find":
|
||||
case "cmd_gotoLine":
|
||||
case "se-cmd-selectAll":
|
||||
result = true;
|
||||
break;
|
||||
case "cmd_findAgain":
|
||||
case "cmd_findPrevious":
|
||||
result = this._editor.lastFind && this._editor.lastFind.lastFound != -1;
|
||||
break;
|
||||
case "se-cmd-undo":
|
||||
result = this._editor.canUndo();
|
||||
break;
|
||||
case "se-cmd-redo":
|
||||
result = this._editor.canRedo();
|
||||
break;
|
||||
case "se-cmd-cut":
|
||||
case "se-cmd-delete": {
|
||||
let selection = this._editor.getSelection();
|
||||
result = selection.start != selection.end && !this._editor.readOnly;
|
||||
break;
|
||||
}
|
||||
case "se-cmd-paste": {
|
||||
let window = this._editor._view._frameWindow;
|
||||
let controller = window.controllers.getControllerForCommand("cmd_paste");
|
||||
result = !this._editor.readOnly &&
|
||||
controller.isCommandEnabled("cmd_paste");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Perform a command.
|
||||
*
|
||||
* @param string aCommand
|
||||
* The command name you want to execute.
|
||||
* @return void
|
||||
*/
|
||||
doCommand: function SEC_doCommand(aCommand)
|
||||
{
|
||||
switch (aCommand) {
|
||||
case "cmd_find":
|
||||
this._editor.ui.find();
|
||||
break;
|
||||
case "cmd_findAgain":
|
||||
this._editor.ui.findNext();
|
||||
break;
|
||||
case "cmd_findPrevious":
|
||||
this._editor.ui.findPrevious();
|
||||
break;
|
||||
case "cmd_gotoLine":
|
||||
this._editor.ui.gotoLine();
|
||||
break;
|
||||
case "se-cmd-selectAll":
|
||||
this._editor._view.invokeAction("selectAll");
|
||||
break;
|
||||
case "se-cmd-undo":
|
||||
this._editor.undo();
|
||||
break;
|
||||
case "se-cmd-redo":
|
||||
this._editor.redo();
|
||||
break;
|
||||
case "se-cmd-cut":
|
||||
this._editor.ui._ownerWindow.goDoCommand("cmd_cut");
|
||||
break;
|
||||
case "se-cmd-paste":
|
||||
this._editor.ui._ownerWindow.goDoCommand("cmd_paste");
|
||||
break;
|
||||
case "se-cmd-delete": {
|
||||
let selection = this._editor.getSelection();
|
||||
this._editor.setText("", selection.start, selection.end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function() { }
|
||||
};
|
|
@ -1,455 +0,0 @@
|
|||
/* vim:set ts=2 sw=2 sts=2 et 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 Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor-ui.jsm");
|
||||
|
||||
const PREF_EDITOR_COMPONENT = "devtools.editor.component";
|
||||
const SOURCEEDITOR_L10N = "chrome://browser/locale/devtools/sourceeditor.properties";
|
||||
|
||||
var component = Services.prefs.getCharPref(PREF_EDITOR_COMPONENT);
|
||||
var obj = {};
|
||||
try {
|
||||
if (component == "ui") {
|
||||
throw new Error("The ui editor component is not available.");
|
||||
}
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor-" + component + ".jsm", obj);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
Cu.reportError("SourceEditor component failed to load: " + component);
|
||||
|
||||
// If the component does not exist, clear the user pref back to the default.
|
||||
Services.prefs.clearUserPref(PREF_EDITOR_COMPONENT);
|
||||
|
||||
// Load the default editor component.
|
||||
component = Services.prefs.getCharPref(PREF_EDITOR_COMPONENT);
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor-" + component + ".jsm", obj);
|
||||
}
|
||||
|
||||
// Export the SourceEditor.
|
||||
this.SourceEditor = obj.SourceEditor;
|
||||
this.EXPORTED_SYMBOLS = ["SourceEditor"];
|
||||
|
||||
// Add the constants used by all SourceEditors.
|
||||
|
||||
XPCOMUtils.defineLazyGetter(SourceEditorUI, "strings", function() {
|
||||
return Services.strings.createBundle(SOURCEEDITOR_L10N);
|
||||
});
|
||||
|
||||
/**
|
||||
* Known SourceEditor preferences.
|
||||
*/
|
||||
SourceEditor.PREFS = {
|
||||
TAB_SIZE: "devtools.editor.tabsize",
|
||||
EXPAND_TAB: "devtools.editor.expandtab",
|
||||
COMPONENT: PREF_EDITOR_COMPONENT,
|
||||
};
|
||||
|
||||
/**
|
||||
* Predefined source editor modes for JavaScript, CSS and other languages.
|
||||
*/
|
||||
SourceEditor.MODES = {
|
||||
JAVASCRIPT: "js",
|
||||
CSS: "css",
|
||||
TEXT: "text",
|
||||
HTML: "html",
|
||||
XML: "xml",
|
||||
};
|
||||
|
||||
/**
|
||||
* Predefined themes for syntax highlighting.
|
||||
*/
|
||||
SourceEditor.THEMES = {
|
||||
MOZILLA: "mozilla",
|
||||
};
|
||||
|
||||
/**
|
||||
* Source editor configuration defaults.
|
||||
* @see SourceEditor.init
|
||||
*/
|
||||
SourceEditor.DEFAULTS = {
|
||||
/**
|
||||
* The text you want shown when the editor opens up.
|
||||
* @type string
|
||||
*/
|
||||
initialText: "",
|
||||
|
||||
/**
|
||||
* The editor mode, based on the file type you want to edit. You can use one of
|
||||
* the predefined modes.
|
||||
*
|
||||
* @see SourceEditor.MODES
|
||||
* @type string
|
||||
*/
|
||||
mode: SourceEditor.MODES.TEXT,
|
||||
|
||||
/**
|
||||
* The syntax highlighting theme you want. You can use one of the predefined
|
||||
* themes, or you can point to your CSS file.
|
||||
*
|
||||
* @see SourceEditor.THEMES.
|
||||
* @type string
|
||||
*/
|
||||
theme: SourceEditor.THEMES.MOZILLA,
|
||||
|
||||
/**
|
||||
* How many steps should the undo stack hold.
|
||||
* @type number
|
||||
*/
|
||||
undoLimit: 200,
|
||||
|
||||
/**
|
||||
* Define how many spaces to use for a tab character. This value is overridden
|
||||
* by a user preference, see SourceEditor.PREFS.TAB_SIZE.
|
||||
*
|
||||
* @type number
|
||||
*/
|
||||
tabSize: 4,
|
||||
|
||||
/**
|
||||
* Tells if you want tab characters to be expanded to spaces. This value is
|
||||
* overridden by a user preference, see SourceEditor.PREFS.EXPAND_TAB.
|
||||
* @type boolean
|
||||
*/
|
||||
expandTab: true,
|
||||
|
||||
/**
|
||||
* Tells if you want the editor to be read only or not.
|
||||
* @type boolean
|
||||
*/
|
||||
readOnly: false,
|
||||
|
||||
/**
|
||||
* Display the line numbers gutter.
|
||||
* @type boolean
|
||||
*/
|
||||
showLineNumbers: false,
|
||||
|
||||
/**
|
||||
* Display the annotations gutter/ruler. This gutter currently supports
|
||||
* annotations of breakpoint type.
|
||||
* @type boolean
|
||||
*/
|
||||
showAnnotationRuler: false,
|
||||
|
||||
/**
|
||||
* Display the overview gutter/ruler. This gutter presents an overview of the
|
||||
* current annotations in the editor, for example the breakpoints.
|
||||
* @type boolean
|
||||
*/
|
||||
showOverviewRuler: false,
|
||||
|
||||
/**
|
||||
* Highlight the current line.
|
||||
* @type boolean
|
||||
*/
|
||||
highlightCurrentLine: true,
|
||||
|
||||
/**
|
||||
* An array of objects that allows you to define custom editor keyboard
|
||||
* bindings. Each object can have:
|
||||
* - action - name of the editor action to invoke.
|
||||
* - code - keyCode for the shortcut.
|
||||
* - accel - boolean for the Accel key (Cmd on Macs, Ctrl on Linux/Windows).
|
||||
* - ctrl - boolean for the Control key
|
||||
* - shift - boolean for the Shift key.
|
||||
* - alt - boolean for the Alt key.
|
||||
* - callback - optional function to invoke, if the action is not predefined
|
||||
* in the editor.
|
||||
* @type array
|
||||
*/
|
||||
keys: null,
|
||||
|
||||
/**
|
||||
* The editor context menu you want to display when the user right-clicks
|
||||
* within the editor. This property can be:
|
||||
* - a string that tells the ID of the xul:menupopup you want. This needs to
|
||||
* be available within the editor parentElement.ownerDocument.
|
||||
* - an nsIDOMElement object reference pointing to the xul:menupopup you
|
||||
* want to open when the contextmenu event is fired.
|
||||
*
|
||||
* Set this property to a falsey value to disable the default context menu.
|
||||
*
|
||||
* @see SourceEditor.EVENTS.CONTEXT_MENU for more control over the contextmenu
|
||||
* event.
|
||||
* @type string|nsIDOMElement
|
||||
*/
|
||||
contextMenu: "sourceEditorContextMenu",
|
||||
};
|
||||
|
||||
/**
|
||||
* Known editor events you can listen for.
|
||||
*/
|
||||
SourceEditor.EVENTS = {
|
||||
/**
|
||||
* The contextmenu event is fired when the editor context menu is invoked. The
|
||||
* event object properties:
|
||||
* - x - the pointer location on the x axis, relative to the document the
|
||||
* user is editing.
|
||||
* - y - the pointer location on the y axis, relative to the document the
|
||||
* user is editing.
|
||||
* - screenX - the pointer location on the x axis, relative to the screen.
|
||||
* This value comes from the DOM contextmenu event.screenX property.
|
||||
* - screenY - the pointer location on the y axis, relative to the screen.
|
||||
* This value comes from the DOM contextmenu event.screenY property.
|
||||
*
|
||||
* @see SourceEditor.DEFAULTS.contextMenu
|
||||
*/
|
||||
CONTEXT_MENU: "ContextMenu",
|
||||
|
||||
/**
|
||||
* The TextChanged event is fired when the editor content changes. The event
|
||||
* object properties:
|
||||
* - start - the character offset in the document where the change has
|
||||
* occured.
|
||||
* - removedCharCount - the number of characters removed from the document.
|
||||
* - addedCharCount - the number of characters added to the document.
|
||||
*/
|
||||
TEXT_CHANGED: "TextChanged",
|
||||
|
||||
/**
|
||||
* The Selection event is fired when the editor selection changes. The event
|
||||
* object properties:
|
||||
* - oldValue - the old selection range.
|
||||
* - newValue - the new selection range.
|
||||
* Both ranges are objects which hold two properties: start and end.
|
||||
*/
|
||||
SELECTION: "Selection",
|
||||
|
||||
/**
|
||||
* The focus event is fired when the editor is focused.
|
||||
*/
|
||||
FOCUS: "Focus",
|
||||
|
||||
/**
|
||||
* The blur event is fired when the editor goes out of focus.
|
||||
*/
|
||||
BLUR: "Blur",
|
||||
|
||||
/**
|
||||
* The MouseMove event is sent when the user moves the mouse over a line.
|
||||
* The event object properties:
|
||||
* - event - the DOM mousemove event object.
|
||||
* - x and y - the mouse coordinates relative to the document being edited.
|
||||
*/
|
||||
MOUSE_MOVE: "MouseMove",
|
||||
|
||||
/**
|
||||
* The MouseOver event is sent when the mouse pointer enters a line.
|
||||
* The event object properties:
|
||||
* - event - the DOM mouseover event object.
|
||||
* - x and y - the mouse coordinates relative to the document being edited.
|
||||
*/
|
||||
MOUSE_OVER: "MouseOver",
|
||||
|
||||
/**
|
||||
* This MouseOut event is sent when the mouse pointer exits a line.
|
||||
* The event object properties:
|
||||
* - event - the DOM mouseout event object.
|
||||
* - x and y - the mouse coordinates relative to the document being edited.
|
||||
*/
|
||||
MOUSE_OUT: "MouseOut",
|
||||
|
||||
/**
|
||||
* The BreakpointChange event is fired when a new breakpoint is added or when
|
||||
* a breakpoint is removed - either through API use or through the editor UI.
|
||||
* Event object properties:
|
||||
* - added - array that holds the new breakpoints.
|
||||
* - removed - array that holds the breakpoints that have been removed.
|
||||
* Each object in the added/removed arrays holds two properties: line and
|
||||
* condition.
|
||||
*/
|
||||
BREAKPOINT_CHANGE: "BreakpointChange",
|
||||
|
||||
/**
|
||||
* The DirtyChanged event is fired when the dirty state of the editor is
|
||||
* changed. The dirty state of the editor tells if the are text changes that
|
||||
* have not been saved yet. Event object properties: oldValue and newValue.
|
||||
* Both are booleans telling the old dirty state and the new state,
|
||||
* respectively.
|
||||
*/
|
||||
DIRTY_CHANGED: "DirtyChanged",
|
||||
};
|
||||
|
||||
/**
|
||||
* Allowed vertical alignment options for the line index
|
||||
* when you call SourceEditor.setCaretPosition().
|
||||
*/
|
||||
SourceEditor.VERTICAL_ALIGN = {
|
||||
TOP: 0,
|
||||
CENTER: 1,
|
||||
BOTTOM: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Extend a destination object with properties from a source object.
|
||||
*
|
||||
* @param object aDestination
|
||||
* @param object aSource
|
||||
*/
|
||||
function extend(aDestination, aSource)
|
||||
{
|
||||
for (let name in aSource) {
|
||||
if (!aDestination.hasOwnProperty(name)) {
|
||||
aDestination[name] = aSource[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add methods common to all components.
|
||||
*/
|
||||
extend(SourceEditor.prototype, {
|
||||
// Expose the static constants on the SourceEditor instances.
|
||||
EVENTS: SourceEditor.EVENTS,
|
||||
MODES: SourceEditor.MODES,
|
||||
THEMES: SourceEditor.THEMES,
|
||||
DEFAULTS: SourceEditor.DEFAULTS,
|
||||
VERTICAL_ALIGN: SourceEditor.VERTICAL_ALIGN,
|
||||
|
||||
_lastFind: null,
|
||||
|
||||
/**
|
||||
* Find a string in the editor.
|
||||
*
|
||||
* @param string aString
|
||||
* The string you want to search for. If |aString| is not given the
|
||||
* currently selected text is used.
|
||||
* @param object [aOptions]
|
||||
* Optional find options:
|
||||
* - start: (integer) offset to start searching from. Default: 0 if
|
||||
* backwards is false. If backwards is true then start = text.length.
|
||||
* - ignoreCase: (boolean) tells if you want the search to be case
|
||||
* insensitive or not. Default: false.
|
||||
* - backwards: (boolean) tells if you want the search to go backwards
|
||||
* from the given |start| offset. Default: false.
|
||||
* @return integer
|
||||
* The offset where the string was found.
|
||||
*/
|
||||
find: function SE_find(aString, aOptions)
|
||||
{
|
||||
if (typeof(aString) != "string") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
aOptions = aOptions || {};
|
||||
|
||||
let str = aOptions.ignoreCase ? aString.toLowerCase() : aString;
|
||||
|
||||
let text = this.getText();
|
||||
if (aOptions.ignoreCase) {
|
||||
text = text.toLowerCase();
|
||||
}
|
||||
|
||||
let index = aOptions.backwards ?
|
||||
text.lastIndexOf(str, aOptions.start) :
|
||||
text.indexOf(str, aOptions.start);
|
||||
|
||||
let lastFoundIndex = index;
|
||||
if (index == -1 && this.lastFind && this.lastFind.index > -1 &&
|
||||
this.lastFind.str === aString &&
|
||||
this.lastFind.ignoreCase === !!aOptions.ignoreCase) {
|
||||
lastFoundIndex = this.lastFind.index;
|
||||
}
|
||||
|
||||
this._lastFind = {
|
||||
str: aString,
|
||||
index: index,
|
||||
lastFound: lastFoundIndex,
|
||||
ignoreCase: !!aOptions.ignoreCase,
|
||||
};
|
||||
|
||||
return index;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the next occurrence of the last search operation.
|
||||
*
|
||||
* @param boolean aWrap
|
||||
* Tells if you want to restart the search from the beginning of the
|
||||
* document if the string is not found.
|
||||
* @return integer
|
||||
* The offset where the string was found.
|
||||
*/
|
||||
findNext: function SE_findNext(aWrap)
|
||||
{
|
||||
if (!this.lastFind && this.lastFind.lastFound == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let options = {
|
||||
start: this.lastFind.lastFound + this.lastFind.str.length,
|
||||
ignoreCase: this.lastFind.ignoreCase,
|
||||
};
|
||||
|
||||
let index = this.find(this.lastFind.str, options);
|
||||
if (index == -1 && aWrap) {
|
||||
options.start = 0;
|
||||
index = this.find(this.lastFind.str, options);
|
||||
}
|
||||
|
||||
return index;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the previous occurrence of the last search operation.
|
||||
*
|
||||
* @param boolean aWrap
|
||||
* Tells if you want to restart the search from the end of the
|
||||
* document if the string is not found.
|
||||
* @return integer
|
||||
* The offset where the string was found.
|
||||
*/
|
||||
findPrevious: function SE_findPrevious(aWrap)
|
||||
{
|
||||
if (!this.lastFind && this.lastFind.lastFound == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let options = {
|
||||
start: this.lastFind.lastFound - this.lastFind.str.length,
|
||||
ignoreCase: this.lastFind.ignoreCase,
|
||||
backwards: true,
|
||||
};
|
||||
|
||||
let index;
|
||||
if (options.start > 0) {
|
||||
index = this.find(this.lastFind.str, options);
|
||||
} else {
|
||||
index = this._lastFind.index = -1;
|
||||
}
|
||||
|
||||
if (index == -1 && aWrap) {
|
||||
options.start = this.getCharCount() - 1;
|
||||
index = this.find(this.lastFind.str, options);
|
||||
}
|
||||
|
||||
return index;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Retrieve the last find operation result. This object holds the following
|
||||
* properties:
|
||||
* - str: the last search string.
|
||||
* - index: stores the result of the most recent find operation. This is the
|
||||
* index in the text where |str| was found or -1 otherwise.
|
||||
* - lastFound: tracks the index where |str| was last found, throughout
|
||||
* multiple find operations. This can be -1 if |str| was never found in the
|
||||
* document.
|
||||
* - ignoreCase: tells if the search was case insensitive or not.
|
||||
* @type object
|
||||
*/
|
||||
Object.defineProperty(SourceEditor.prototype, "lastFind", {
|
||||
get: function() { return this._lastFind; },
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
|
@ -9,26 +9,9 @@ support-files =
|
|||
codemirror.html
|
||||
head.js
|
||||
|
||||
[browser_bug650345_find.js]
|
||||
[browser_bug684546_reset_undo.js]
|
||||
[browser_bug684862_paste_html.js]
|
||||
[browser_bug687160_line_api.js]
|
||||
[browser_bug687568_pagescroll.js]
|
||||
[browser_bug687573_vscroll.js]
|
||||
[browser_bug687580_drag_and_drop.js]
|
||||
[browser_bug695035_middle_click_paste.js]
|
||||
[browser_bug700893_dirty_state.js]
|
||||
[browser_bug703692_focus_blur.js]
|
||||
[browser_bug707987_debugger_breakpoints.js]
|
||||
[browser_bug712982_line_ruler_click.js]
|
||||
[browser_bug725388_mouse_events.js]
|
||||
[browser_bug725392_mouse_coords_char_offset.js]
|
||||
[browser_bug725430_comment_uncomment.js]
|
||||
[browser_bug725618_moveLines_shortcut.js]
|
||||
[browser_bug729480_line_vertical_align.js]
|
||||
[browser_bug729960_block_bracket_jump.js]
|
||||
[browser_bug731721_debugger_stepping.js]
|
||||
[browser_bug744021_next_prev_bracket_jump.js]
|
||||
[browser_editor_basic.js]
|
||||
[browser_editor_cursor.js]
|
||||
[browser_editor_history.js]
|
||||
[browser_editor_markers.js]
|
||||
[browser_codemirror.js]
|
||||
skip-if = os == "linux"
|
||||
[browser_sourceeditor_initialization.js]
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 650345' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
let text = "foobar bug650345\nBug650345 bazbaz\nfoobar omg\ntest";
|
||||
editor.setText(text);
|
||||
|
||||
let needle = "foobar";
|
||||
is(editor.find(), -1, "find() works");
|
||||
ok(!editor.lastFind, "no editor.lastFind yet");
|
||||
|
||||
is(editor.find(needle), 0, "find('" + needle + "') works");
|
||||
is(editor.lastFind.str, needle, "lastFind.str is correct");
|
||||
is(editor.lastFind.index, 0, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, 0, "lastFind.lastFound is correct");
|
||||
is(editor.lastFind.ignoreCase, false, "lastFind.ignoreCase is correct");
|
||||
|
||||
let newIndex = text.indexOf(needle, needle.length);
|
||||
is(editor.findNext(), newIndex, "findNext() works");
|
||||
is(editor.lastFind.str, needle, "lastFind.str is correct");
|
||||
is(editor.lastFind.index, newIndex, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex, "lastFind.lastFound is correct");
|
||||
is(editor.lastFind.ignoreCase, false, "lastFind.ignoreCase is correct");
|
||||
|
||||
is(editor.findNext(), -1, "findNext() works again");
|
||||
is(editor.lastFind.index, -1, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findPrevious(), 0, "findPrevious() works");
|
||||
is(editor.lastFind.index, 0, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, 0, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findPrevious(), -1, "findPrevious() works again");
|
||||
is(editor.lastFind.index, -1, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, 0, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findNext(), newIndex, "findNext() works");
|
||||
is(editor.lastFind.index, newIndex, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findNext(true), 0, "findNext(true) works");
|
||||
is(editor.lastFind.index, 0, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, 0, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findNext(true), newIndex, "findNext(true) works again");
|
||||
is(editor.lastFind.index, newIndex, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findPrevious(true), 0, "findPrevious(true) works");
|
||||
is(editor.lastFind.index, 0, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, 0, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findPrevious(true), newIndex, "findPrevious(true) works again");
|
||||
is(editor.lastFind.index, newIndex, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex, "lastFind.lastFound is correct");
|
||||
|
||||
needle = "error";
|
||||
is(editor.find(needle), -1, "find('" + needle + "') works");
|
||||
is(editor.lastFind.str, needle, "lastFind.str is correct");
|
||||
is(editor.lastFind.index, -1, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, -1, "lastFind.lastFound is correct");
|
||||
is(editor.lastFind.ignoreCase, false, "lastFind.ignoreCase is correct");
|
||||
|
||||
is(editor.findNext(), -1, "findNext() works");
|
||||
is(editor.lastFind.str, needle, "lastFind.str is correct");
|
||||
is(editor.lastFind.index, -1, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, -1, "lastFind.lastFound is correct");
|
||||
is(editor.findNext(true), -1, "findNext(true) works");
|
||||
|
||||
is(editor.findPrevious(), -1, "findPrevious() works");
|
||||
is(editor.findPrevious(true), -1, "findPrevious(true) works");
|
||||
|
||||
needle = "bug650345";
|
||||
newIndex = text.indexOf(needle);
|
||||
|
||||
is(editor.find(needle), newIndex, "find('" + needle + "') works");
|
||||
is(editor.findNext(), -1, "findNext() works");
|
||||
is(editor.findNext(true), newIndex, "findNext(true) works");
|
||||
is(editor.findPrevious(), -1, "findPrevious() works");
|
||||
is(editor.findPrevious(true), newIndex, "findPrevious(true) works");
|
||||
is(editor.lastFind.index, newIndex, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.find(needle, {ignoreCase: 1}), newIndex,
|
||||
"find('" + needle + "', {ignoreCase: 1}) works");
|
||||
is(editor.lastFind.ignoreCase, true, "lastFind.ignoreCase is correct");
|
||||
|
||||
let newIndex2 = text.toLowerCase().indexOf(needle, newIndex + needle.length);
|
||||
is(editor.findNext(), newIndex2, "findNext() works");
|
||||
is(editor.findNext(), -1, "findNext() works");
|
||||
is(editor.lastFind.index, -1, "lastFind.index is correct");
|
||||
is(editor.lastFind.lastFound, newIndex2, "lastFind.lastFound is correct");
|
||||
|
||||
is(editor.findNext(true), newIndex, "findNext(true) works");
|
||||
|
||||
is(editor.findPrevious(), -1, "findPrevious() works");
|
||||
is(editor.findPrevious(true), newIndex2, "findPrevious(true) works");
|
||||
is(editor.findPrevious(), newIndex, "findPrevious() works again");
|
||||
|
||||
needle = "foobar";
|
||||
newIndex = text.indexOf(needle, 2);
|
||||
is(editor.find(needle, {start: 2}), newIndex,
|
||||
"find('" + needle + "', {start:2}) works");
|
||||
is(editor.findNext(), -1, "findNext() works");
|
||||
is(editor.findNext(true), 0, "findNext(true) works");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 684546 - reset undo' width='300' height='500'>" +
|
||||
"<box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.setText("First");
|
||||
editor.setText("Second", 5);
|
||||
is(editor.getText(), "FirstSecond", "text set correctly.");
|
||||
editor.undo();
|
||||
is(editor.getText(), "First", "undo works.");
|
||||
editor.redo();
|
||||
is(editor.getText(), "FirstSecond", "redo works.");
|
||||
editor.resetUndo();
|
||||
ok(!editor.canUndo(), "canUndo() is correct");
|
||||
ok(!editor.canRedo(), "canRedo() is correct");
|
||||
editor.undo();
|
||||
is(editor.getText(), "FirstSecond", "reset undo works correctly");
|
||||
editor.setText("Third", 11);
|
||||
is(editor.getText(), "FirstSecondThird", "text set correctly");
|
||||
editor.undo();
|
||||
is(editor.getText(), "FirstSecond", "undo works after reset");
|
||||
editor.redo();
|
||||
is(editor.getText(), "FirstSecondThird", "redo works after reset");
|
||||
editor.resetUndo();
|
||||
ok(!editor.canUndo(), "canUndo() is correct (again)");
|
||||
ok(!editor.canRedo(), "canRedo() is correct (again)");
|
||||
editor.undo();
|
||||
is(editor.getText(), "FirstSecondThird", "reset undo still works correctly");
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
});
|
|
@ -1,119 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const pageUrl = "data:text/html,<ul><li>test<li>foobarBug684862";
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
waitForFocus(pageLoaded, content);
|
||||
}, true);
|
||||
|
||||
content.location = pageUrl;
|
||||
}
|
||||
|
||||
function pageLoaded()
|
||||
{
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 684862 - paste HTML' width='600' height='500'>" +
|
||||
"<script type='application/javascript' src='chrome://global/content/globalOverlay.js'/>" +
|
||||
"<box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let doCopy = function() {
|
||||
gBrowser.selectedBrowser.focus();
|
||||
EventUtils.synthesizeKey("a", {accelKey: true}, content);
|
||||
EventUtils.synthesizeKey("c", {accelKey: true}, content);
|
||||
};
|
||||
|
||||
let clipboardValidator = function(aData) aData.indexOf("foobarBug684862") > -1;
|
||||
|
||||
let onCopy = function() {
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
};
|
||||
|
||||
waitForClipboard(clipboardValidator, doCopy, onCopy, testEnd);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
ok(!editor.getText(), "editor has no content");
|
||||
is(editor.getCaretOffset(), 0, "caret location");
|
||||
|
||||
let onPaste = function() {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
|
||||
|
||||
let text = editor.getText();
|
||||
ok(text, "editor has content after paste");
|
||||
|
||||
let pos = text.indexOf("foobarBug684862");
|
||||
isnot(pos, -1, "editor content is correct");
|
||||
// Test for bug 699541 - Pasted HTML shows twice in Orion.
|
||||
is(text.lastIndexOf("foobarBug684862"), pos, "editor content is correct (no duplicate)");
|
||||
|
||||
executeSoon(function() {
|
||||
editor.setCaretOffset(4);
|
||||
EventUtils.synthesizeKey("a", {}, testWin);
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {}, testWin);
|
||||
|
||||
text = editor.getText();
|
||||
|
||||
is(text.indexOf("foobarBug684862"), pos + 1,
|
||||
"editor content is correct after navigation");
|
||||
is(editor.getCaretOffset(), 6, "caret location");
|
||||
|
||||
executeSoon(testEnd);
|
||||
});
|
||||
};
|
||||
|
||||
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
|
||||
|
||||
// Do paste
|
||||
executeSoon(function() {
|
||||
testWin.goDoCommand("cmd_paste");
|
||||
});
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
}
|
||||
if (testWin) {
|
||||
testWin.close();
|
||||
}
|
||||
testWin = editor = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 660784' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
|
||||
editor.focus();
|
||||
|
||||
editor.setText("line1\nline2\nline3");
|
||||
|
||||
if (component != "textarea") {
|
||||
is(editor.getLineCount(), 3, "getLineCount() works");
|
||||
}
|
||||
|
||||
editor.setCaretPosition(1);
|
||||
is(editor.getCaretOffset(), 6, "setCaretPosition(line) works");
|
||||
|
||||
let pos;
|
||||
if (component != "textarea") {
|
||||
pos = editor.getCaretPosition();
|
||||
ok(pos.line == 1 && pos.col == 0, "getCaretPosition() works");
|
||||
}
|
||||
|
||||
editor.setCaretPosition(1, 3);
|
||||
is(editor.getCaretOffset(), 9, "setCaretPosition(line, column) works");
|
||||
|
||||
if (component != "textarea") {
|
||||
pos = editor.getCaretPosition();
|
||||
ok(pos.line == 1 && pos.col == 3, "getCaretPosition() works");
|
||||
}
|
||||
|
||||
editor.setCaretPosition(2);
|
||||
is(editor.getCaretOffset(), 12, "setCaretLine() works, confirmed");
|
||||
|
||||
if (component != "textarea") {
|
||||
pos = editor.getCaretPosition();
|
||||
ok(pos.line == 2 && pos.col == 0, "setCaretPosition(line) works, again");
|
||||
}
|
||||
|
||||
let offsetLine = editor.getLineAtOffset(0);
|
||||
is(offsetLine, 0, "getLineAtOffset() is correct for offset 0");
|
||||
|
||||
let offsetLine = editor.getLineAtOffset(6);
|
||||
is(offsetLine, 1, "getLineAtOffset() is correct for offset 6");
|
||||
|
||||
let offsetLine = editor.getLineAtOffset(12);
|
||||
is(offsetLine, 2, "getLineAtOffset() is correct for offset 12");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component != "orion") {
|
||||
ok(true, "skip test for bug 687568: only applicable for Orion");
|
||||
return; // Testing for the fix requires direct Orion API access.
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 687568 - page scroll' width='600' height='500'>" +
|
||||
"<box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, { showLineNumbers: true }, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
let view = editor._view;
|
||||
let model = editor._model;
|
||||
|
||||
let lineHeight = view.getLineHeight();
|
||||
let editorHeight = view.getClientArea().height;
|
||||
let linesPerPage = Math.floor(editorHeight / lineHeight);
|
||||
let totalLines = 3 * linesPerPage;
|
||||
|
||||
let text = "";
|
||||
for (let i = 0; i < totalLines; i++) {
|
||||
text += "l" + i + "\n";
|
||||
}
|
||||
|
||||
editor.setText(text);
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
|
||||
|
||||
let bottomLine = view.getBottomIndex(true);
|
||||
view.setTopIndex(bottomLine + 1);
|
||||
|
||||
executeSoon(function() {
|
||||
EventUtils.synthesizeKey("VK_PAGE_DOWN", {shiftKey: true}, testWin);
|
||||
|
||||
executeSoon(function() {
|
||||
let topLine = view.getTopIndex(true);
|
||||
let topLineOffset = model.getLineStart(topLine);
|
||||
let selection = editor.getSelection();
|
||||
ok(selection.start < topLineOffset && topLineOffset < selection.end,
|
||||
"top visible line is selected");
|
||||
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component == "textarea") {
|
||||
ok(true, "skip test for bug 687573: not applicable for TEXTAREAs");
|
||||
return; // TEXTAREAs have different behavior
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 687573 - vertical scroll' width='300' height='500'>" +
|
||||
"<box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
let text = "abba\n" +
|
||||
"\n" +
|
||||
"abbaabbaabbaabbaabbaabbaabbaabbaabbaabba\n" +
|
||||
"abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\n" +
|
||||
"abbaabbaabbaabbaabbaabbaabbaabbaabbaabba\n" +
|
||||
"\n" +
|
||||
"abba\n";
|
||||
|
||||
let config = {
|
||||
showLineNumbers: true,
|
||||
initialText: text,
|
||||
};
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, config, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
let VK_LINE_END = "VK_END";
|
||||
let VK_LINE_END_OPT = {};
|
||||
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
|
||||
if (OS == "Darwin") {
|
||||
VK_LINE_END = "VK_RIGHT";
|
||||
VK_LINE_END_OPT = {accelKey: true};
|
||||
}
|
||||
|
||||
editor.focus();
|
||||
|
||||
editor.setCaretOffset(0);
|
||||
is(editor.getCaretOffset(), 0, "caret location at start");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
|
||||
// line 3
|
||||
is(editor.getCaretOffset(), 6, "caret location, keypress Down two times, line 3");
|
||||
|
||||
// line 3 end
|
||||
EventUtils.synthesizeKey(VK_LINE_END, VK_LINE_END_OPT, testWin);
|
||||
is(editor.getCaretOffset(), 46, "caret location, keypress End, line 3 end");
|
||||
|
||||
// line 4
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
is(editor.getCaretOffset(), 87, "caret location, keypress Down, line 4");
|
||||
|
||||
// line 4 end
|
||||
EventUtils.synthesizeKey(VK_LINE_END, VK_LINE_END_OPT, testWin);
|
||||
is(editor.getCaretOffset(), 135, "caret location, keypress End, line 4 end");
|
||||
|
||||
// line 5 end
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
is(editor.getCaretOffset(), 176, "caret location, keypress Down, line 5 end");
|
||||
|
||||
// line 6 end
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
is(editor.getCaretOffset(), 177, "caret location, keypress Down, line 6 end");
|
||||
|
||||
// The executeSoon() calls are needed to allow reflows...
|
||||
EventUtils.synthesizeKey("VK_UP", {}, testWin);
|
||||
executeSoon(function() {
|
||||
// line 5 end
|
||||
is(editor.getCaretOffset(), 176, "caret location, keypress Up, line 5 end");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {}, testWin);
|
||||
executeSoon(function() {
|
||||
// line 4 end
|
||||
is(editor.getCaretOffset(), 135, "caret location, keypress Up, line 4 end");
|
||||
|
||||
// line 3 end
|
||||
EventUtils.synthesizeKey("VK_UP", {}, testWin);
|
||||
is(editor.getCaretOffset(), 46, "caret location, keypress Up, line 3 end");
|
||||
|
||||
// line 2 end
|
||||
EventUtils.synthesizeKey("VK_UP", {}, testWin);
|
||||
is(editor.getCaretOffset(), 5, "caret location, keypress Up, line 2 end");
|
||||
|
||||
// line 3 end
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
is(editor.getCaretOffset(), 46, "caret location, keypress Down, line 3 end");
|
||||
|
||||
// line 4 end
|
||||
EventUtils.synthesizeKey("VK_DOWN", {}, testWin);
|
||||
is(editor.getCaretOffset(), 135, "caret location, keypress Down, line 4 end");
|
||||
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component != "orion") {
|
||||
ok(true, "skip test for bug 687580: only applicable for Orion");
|
||||
return; // Testing for the fix requires direct Orion API access.
|
||||
}
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 687580 - drag and drop' width='600' height='500'>" +
|
||||
"<box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
let view = editor._view;
|
||||
let model = editor._model;
|
||||
|
||||
let lineHeight = view.getLineHeight();
|
||||
let editorHeight = view.getClientArea().height;
|
||||
let linesPerPage = Math.floor(editorHeight / lineHeight);
|
||||
let totalLines = 2 * linesPerPage;
|
||||
|
||||
let text = "foobarBug687580-";
|
||||
for (let i = 0; i < totalLines; i++) {
|
||||
text += "l" + i + "\n";
|
||||
}
|
||||
|
||||
editor.setText(text);
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
let bottomPixel = view.getBottomPixel();
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("VK_DOWN", {shiftKey: true}, testWin);
|
||||
|
||||
let initialSelection = editor.getSelection();
|
||||
|
||||
let ds = Cc["@mozilla.org/widget/dragservice;1"].
|
||||
getService(Ci.nsIDragService);
|
||||
|
||||
let target = view._clientDiv;
|
||||
let targetWin = target.ownerDocument.defaultView;
|
||||
|
||||
let dataTransfer = null;
|
||||
|
||||
let onDragStart = function(aEvent) {
|
||||
target.removeEventListener("dragstart", onDragStart, false);
|
||||
|
||||
dataTransfer = aEvent.dataTransfer;
|
||||
ok(dataTransfer, "dragstart event fired");
|
||||
ok(dataTransfer.types.contains("text/plain"),
|
||||
"dataTransfer text/plain available");
|
||||
let text = dataTransfer.getData("text/plain");
|
||||
isnot(text.indexOf("foobarBug687580"), -1, "text/plain data is correct");
|
||||
|
||||
dataTransfer.dropEffect = "move";
|
||||
};
|
||||
|
||||
let onDrop = executeSoon.bind(null, function() {
|
||||
target.removeEventListener("drop", onDrop, false);
|
||||
|
||||
let selection = editor.getSelection();
|
||||
is(selection.end - selection.start,
|
||||
initialSelection.end - initialSelection.start,
|
||||
"selection is correct");
|
||||
is(editor.getText(0, 2), "l3", "drag and drop worked");
|
||||
|
||||
let offset = editor.getCaretOffset();
|
||||
ok(offset > initialSelection.end, "new caret location");
|
||||
|
||||
let initialLength = initialSelection.end - initialSelection.start;
|
||||
let dropText = editor.getText(offset - initialLength, offset);
|
||||
isnot(dropText.indexOf("foobarBug687580"), -1, "drop text is correct");
|
||||
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
});
|
||||
|
||||
executeSoon(function() {
|
||||
ds.startDragSession();
|
||||
|
||||
target.addEventListener("dragstart", onDragStart, false);
|
||||
target.addEventListener("drop", onDrop, false);
|
||||
|
||||
EventUtils.synthesizeMouse(target, 10, 10, {type: "mousedown"}, targetWin);
|
||||
|
||||
EventUtils.synthesizeMouse(target, 11, bottomPixel - 25, {type: "mousemove"},
|
||||
targetWin);
|
||||
|
||||
EventUtils.synthesizeMouse(target, 12, bottomPixel - 15, {type: "mousemove"},
|
||||
targetWin);
|
||||
|
||||
let clientX = 5;
|
||||
let clientY = bottomPixel - 10;
|
||||
|
||||
let event = targetWin.document.createEvent("DragEvents");
|
||||
event.initDragEvent("dragenter", true, true, targetWin, 0, 0, 0, clientX,
|
||||
clientY, false, false, false, false, 0, null,
|
||||
dataTransfer);
|
||||
target.dispatchEvent(event);
|
||||
|
||||
event = targetWin.document.createEvent("DragEvents");
|
||||
event.initDragEvent("dragover", true, true, targetWin, 0, 0, 0, clientX + 1,
|
||||
clientY + 2, false, false, false, false, 0, null,
|
||||
dataTransfer);
|
||||
target.dispatchEvent(event);
|
||||
|
||||
EventUtils.synthesizeMouse(target, clientX + 2, clientY + 1,
|
||||
{type: "mouseup"}, targetWin);
|
||||
|
||||
event = targetWin.document.createEvent("DragEvents");
|
||||
event.initDragEvent("drop", true, true, targetWin, 0, 0, 0, clientX + 2,
|
||||
clientY + 3, false, false, false, false, 0, null,
|
||||
dataTransfer);
|
||||
target.dispatchEvent(event);
|
||||
|
||||
event = targetWin.document.createEvent("DragEvents");
|
||||
event.initDragEvent("dragend", true, true, targetWin, 0, 0, 0, clientX + 3,
|
||||
clientY + 2, false, false, false, false, 0, null,
|
||||
dataTransfer);
|
||||
target.dispatchEvent(event);
|
||||
|
||||
ds.endDragSession(true);
|
||||
});
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
if (Services.appinfo.OS != "Linux") {
|
||||
ok(true, "this test only applies to Linux, skipping.")
|
||||
return;
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 695035' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
let initialText = "initial text!";
|
||||
|
||||
editor.setText(initialText);
|
||||
|
||||
let expectedString = "foobarBug695035-" + Date.now();
|
||||
|
||||
let doCopy = function() {
|
||||
let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].
|
||||
getService(Ci.nsIClipboardHelper);
|
||||
clipboardHelper.copyStringToClipboard(expectedString,
|
||||
Ci.nsIClipboard.kSelectionClipboard,
|
||||
testWin.document);
|
||||
};
|
||||
|
||||
let onCopy = function() {
|
||||
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
|
||||
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 10, 10, {}, testWin);
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 11, 11, {button: 1}, testWin);
|
||||
};
|
||||
|
||||
let onPaste = function() {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste);
|
||||
|
||||
let text = editor.getText();
|
||||
isnot(text.indexOf(expectedString), -1, "middle-click paste works");
|
||||
isnot(text, initialText, "middle-click paste works (confirmed)");
|
||||
|
||||
executeSoon(doTestBug695032);
|
||||
};
|
||||
|
||||
let doTestBug695032 = function() {
|
||||
info("test for bug 695032 - editor selection should be placed in the X11 primary selection buffer");
|
||||
|
||||
let text = "foobarBug695032 test me, test me!";
|
||||
editor.setText(text);
|
||||
|
||||
waitForSelection(text, function() {
|
||||
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
|
||||
}, testEnd, testEnd);
|
||||
};
|
||||
|
||||
waitForSelection(expectedString, doCopy, onCopy, testEnd);
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component == "textarea") {
|
||||
ok(true, "skip test for bug 700893: only applicable for non-textarea components");
|
||||
return;
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 700893' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {initialText: "foobar"}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
is(editor.dirty, false, "editory is not dirty");
|
||||
|
||||
let event = null;
|
||||
let eventHandler = function(aEvent) {
|
||||
event = aEvent;
|
||||
};
|
||||
editor.addEventListener(SourceEditor.EVENTS.DIRTY_CHANGED, eventHandler);
|
||||
|
||||
editor.setText("omg");
|
||||
|
||||
is(editor.dirty, true, "editor is dirty");
|
||||
ok(event, "DirtyChanged event fired")
|
||||
is(event.oldValue, false, "event.oldValue is correct");
|
||||
is(event.newValue, true, "event.newValue is correct");
|
||||
|
||||
event = null;
|
||||
editor.setText("foo 2");
|
||||
ok(!event, "no DirtyChanged event fired");
|
||||
|
||||
editor.dirty = false;
|
||||
|
||||
is(editor.dirty, false, "editor marked as clean");
|
||||
ok(event, "DirtyChanged event fired")
|
||||
is(event.oldValue, true, "event.oldValue is correct");
|
||||
is(event.newValue, false, "event.newValue is correct");
|
||||
|
||||
event = null;
|
||||
editor.setText("foo 3");
|
||||
|
||||
is(editor.dirty, true, "editor is dirty after changes");
|
||||
ok(event, "DirtyChanged event fired")
|
||||
is(event.oldValue, false, "event.oldValue is correct");
|
||||
is(event.newValue, true, "event.newValue is correct");
|
||||
|
||||
editor.undo();
|
||||
is(editor.dirty, false, "editor is not dirty after undo");
|
||||
ok(event, "DirtyChanged event fired")
|
||||
is(event.oldValue, true, "event.oldValue is correct");
|
||||
is(event.newValue, false, "event.newValue is correct");
|
||||
|
||||
editor.removeEventListener(SourceEditor.EVENTS.DIRTY_CHANGED, eventHandler);
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='Test for bug 703692' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
let focusHandler = function(aEvent) {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.FOCUS, focusHandler);
|
||||
editor.addEventListener(SourceEditor.EVENTS.BLUR, blurHandler);
|
||||
|
||||
ok(aEvent, "Focus event fired");
|
||||
window.focus();
|
||||
};
|
||||
|
||||
let blurHandler = function(aEvent) {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.BLUR, blurHandler);
|
||||
|
||||
ok(aEvent, "Blur event fired");
|
||||
executeSoon(testEnd);
|
||||
}
|
||||
|
||||
editor.addEventListener(SourceEditor.EVENTS.FOCUS, focusHandler);
|
||||
|
||||
editor.focus();
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
}
|
||||
if (testWin) {
|
||||
testWin.close();
|
||||
}
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component == "textarea") {
|
||||
ok(true, "skip test for bug 707987: only applicable for non-textarea components");
|
||||
return;
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 707987' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {showAnnotationRuler: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
editor.setText("line1\nline2\nline3\nline4");
|
||||
|
||||
is(editor.getBreakpoints().length, 0, "no breakpoints");
|
||||
|
||||
let event = null;
|
||||
let eventHandler = function(aEvent) {
|
||||
event = aEvent;
|
||||
};
|
||||
editor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, eventHandler);
|
||||
|
||||
// Add breakpoint at line 0
|
||||
|
||||
editor.addBreakpoint(0);
|
||||
|
||||
let breakpoints = editor.getBreakpoints();
|
||||
is(breakpoints.length, 1, "one breakpoint added");
|
||||
is(breakpoints[0].line, 0, "breakpoint[0].line is correct");
|
||||
ok(!breakpoints[0].condition, "breakpoint[0].condition is correct");
|
||||
|
||||
ok(event, "breakpoint event fired");
|
||||
is(event.added.length, 1, "one breakpoint added (confirmed)");
|
||||
is(event.removed.length, 0, "no breakpoint removed");
|
||||
is(event.added[0].line, 0, "event added[0].line is correct");
|
||||
ok(!event.added[0].condition, "event added[0].condition is correct");
|
||||
|
||||
// Add breakpoint at line 3
|
||||
|
||||
event = null;
|
||||
editor.addBreakpoint(3, "foo == 'bar'");
|
||||
|
||||
breakpoints = editor.getBreakpoints();
|
||||
is(breakpoints.length, 2, "another breakpoint added");
|
||||
is(breakpoints[0].line, 0, "breakpoint[0].line is correct");
|
||||
ok(!breakpoints[0].condition, "breakpoint[0].condition is correct");
|
||||
is(breakpoints[1].line, 3, "breakpoint[1].line is correct");
|
||||
is(breakpoints[1].condition, "foo == 'bar'",
|
||||
"breakpoint[1].condition is correct");
|
||||
|
||||
ok(event, "breakpoint event fired");
|
||||
is(event.added.length, 1, "another breakpoint added (confirmed)");
|
||||
is(event.removed.length, 0, "no breakpoint removed");
|
||||
is(event.added[0].line, 3, "event added[0].line is correct");
|
||||
is(event.added[0].condition, "foo == 'bar'",
|
||||
"event added[0].condition is correct");
|
||||
|
||||
// Try to add another breakpoint at line 0
|
||||
|
||||
event = null;
|
||||
editor.addBreakpoint(0);
|
||||
|
||||
is(editor.getBreakpoints().length, 2, "no breakpoint added");
|
||||
is(event, null, "no breakpoint event fired");
|
||||
|
||||
// Try to remove a breakpoint from line 1
|
||||
|
||||
is(editor.removeBreakpoint(1), false, "removeBreakpoint(1) returns false");
|
||||
is(editor.getBreakpoints().length, 2, "no breakpoint removed");
|
||||
is(event, null, "no breakpoint event fired");
|
||||
|
||||
// Remove the breakpoint from line 0
|
||||
|
||||
is(editor.removeBreakpoint(0), true, "removeBreakpoint(0) returns true");
|
||||
|
||||
breakpoints = editor.getBreakpoints();
|
||||
is(breakpoints[0].line, 3, "breakpoint[0].line is correct");
|
||||
is(breakpoints[0].condition, "foo == 'bar'",
|
||||
"breakpoint[0].condition is correct");
|
||||
|
||||
ok(event, "breakpoint event fired");
|
||||
is(event.added.length, 0, "no breakpoint added");
|
||||
is(event.removed.length, 1, "one breakpoint removed");
|
||||
is(event.removed[0].line, 0, "event removed[0].line is correct");
|
||||
ok(!event.removed[0].condition, "event removed[0].condition is correct");
|
||||
|
||||
// Remove the breakpoint from line 3
|
||||
|
||||
event = null;
|
||||
is(editor.removeBreakpoint(3), true, "removeBreakpoint(3) returns true");
|
||||
|
||||
is(editor.getBreakpoints().length, 0, "no breakpoints");
|
||||
ok(event, "breakpoint event fired");
|
||||
is(event.added.length, 0, "no breakpoint added");
|
||||
is(event.removed.length, 1, "one breakpoint removed");
|
||||
is(event.removed[0].line, 3, "event removed[0].line is correct");
|
||||
is(event.removed[0].condition, "foo == 'bar'",
|
||||
"event removed[0].condition is correct");
|
||||
|
||||
// Add a breakpoint with the mouse
|
||||
|
||||
event = null;
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 10, 10, {}, testWin);
|
||||
|
||||
breakpoints = editor.getBreakpoints();
|
||||
is(breakpoints.length, 1, "one breakpoint added");
|
||||
is(breakpoints[0].line, 0, "breakpoint[0].line is correct");
|
||||
ok(!breakpoints[0].condition, "breakpoint[0].condition is correct");
|
||||
|
||||
ok(event, "breakpoint event fired");
|
||||
is(event.added.length, 1, "one breakpoint added (confirmed)");
|
||||
is(event.removed.length, 0, "no breakpoint removed");
|
||||
is(event.added[0].line, 0, "event added[0].line is correct");
|
||||
ok(!event.added[0].condition, "event added[0].condition is correct");
|
||||
|
||||
// Remove a breakpoint with the mouse
|
||||
|
||||
event = null;
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 10, 10, {}, testWin);
|
||||
|
||||
breakpoints = editor.getBreakpoints();
|
||||
is(breakpoints.length, 0, "one breakpoint removed");
|
||||
|
||||
ok(event, "breakpoint event fired");
|
||||
is(event.added.length, 0, "no breakpoint added");
|
||||
is(event.removed.length, 1, "one breakpoint removed (confirmed)");
|
||||
is(event.removed[0].line, 0, "event removed[0].line is correct");
|
||||
ok(!event.removed[0].condition, "event removed[0].condition is correct");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component == "textarea") {
|
||||
ok(true, "skip test for bug 712982: only applicable for non-textarea components");
|
||||
return;
|
||||
}
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 712982' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {showLineNumbers: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
editor.setText("line1\nline2\nline3\nline4");
|
||||
|
||||
editor.setCaretPosition(3);
|
||||
let pos = editor.getCaretPosition();
|
||||
ok(pos.line == 3 && pos.col == 0, "initial caret location is correct");
|
||||
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 10, 10, {}, testWin);
|
||||
|
||||
is(editor.getCaretOffset(), 0, "click on line 0 worked");
|
||||
|
||||
editor.setCaretPosition(2);
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 11, 11,
|
||||
{shiftKey: true}, testWin);
|
||||
is(editor.getSelectedText().trim(), "line1\nline2", "shift+click works");
|
||||
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
EventUtils.synthesizeMouse(editor.editorElement, 10, 10,
|
||||
{clickCount: 2}, testWin);
|
||||
|
||||
is(editor.getSelectedText().trim(), "line1", "double click works");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='Test for bug 725388' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
testWin.resizeBy(1, 2);
|
||||
|
||||
let text = "BrowserBug - 725388";
|
||||
editor.setText(text);
|
||||
|
||||
let target = editor.editorElement;
|
||||
let targetWin = target.ownerDocument.defaultView;
|
||||
|
||||
let eventsFired = 0;
|
||||
|
||||
let done = function() {
|
||||
eventsFired++;
|
||||
if (eventsFired == 3) {
|
||||
executeSoon(testEnd);
|
||||
}
|
||||
};
|
||||
|
||||
let mMoveHandler = function(aEvent) {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.MOUSE_MOVE, mMoveHandler);
|
||||
|
||||
is(aEvent.event.type, "mousemove", "MouseMove event fired.");
|
||||
|
||||
executeSoon(done);
|
||||
};
|
||||
|
||||
let mOverHandler = function(aEvent) {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.MOUSE_OVER, mOverHandler);
|
||||
|
||||
is(aEvent.event.type, "mouseover", "MouseOver event fired.");
|
||||
|
||||
executeSoon(done);
|
||||
};
|
||||
|
||||
let mOutHandler = function(aEvent) {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.MOUSE_OUT, mOutHandler);
|
||||
|
||||
is(aEvent.event.type, "mouseout", "MouseOut event fired.");
|
||||
|
||||
executeSoon(done);
|
||||
};
|
||||
|
||||
editor.addEventListener(SourceEditor.EVENTS.MOUSE_OVER, mOverHandler);
|
||||
editor.addEventListener(SourceEditor.EVENTS.MOUSE_MOVE, mMoveHandler);
|
||||
editor.addEventListener(SourceEditor.EVENTS.MOUSE_OUT, mOutHandler);
|
||||
|
||||
waitForFocus(function() {
|
||||
EventUtils.synthesizeMouse(target, 10, 10, {type: "mouseover"},
|
||||
targetWin);
|
||||
EventUtils.synthesizeMouse(target, 15, 17, {type: "mousemove"},
|
||||
targetWin);
|
||||
EventUtils.synthesizeMouse(target, -10, -10, {type: "mouseout"},
|
||||
targetWin);
|
||||
}, targetWin);
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
}
|
||||
if (testWin) {
|
||||
testWin.close();
|
||||
}
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test()
|
||||
{
|
||||
let testWin;
|
||||
let editor;
|
||||
let mousePos = { x: 36, y: 4 };
|
||||
let expectedOffset = 5;
|
||||
let maxDiff = 10;
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function editorLoaded(aEditor, aWindow)
|
||||
{
|
||||
editor = aEditor;
|
||||
testWin = aWindow;
|
||||
|
||||
let text = fillEditor(editor, 3);
|
||||
editor.setText(text);
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
doMouseMove(testPage1);
|
||||
}
|
||||
|
||||
function doMouseMove(aCallback)
|
||||
{
|
||||
function mouseEventHandler(aEvent)
|
||||
{
|
||||
editor.removeEventListener(editor.EVENTS.MOUSE_OUT, mouseEventHandler);
|
||||
editor.removeEventListener(editor.EVENTS.MOUSE_OVER, mouseEventHandler);
|
||||
editor.removeEventListener(editor.EVENTS.MOUSE_MOVE, mouseEventHandler);
|
||||
|
||||
executeSoon(aCallback.bind(null, aEvent));
|
||||
}
|
||||
|
||||
editor.addEventListener(editor.EVENTS.MOUSE_MOVE, mouseEventHandler);
|
||||
editor.addEventListener(editor.EVENTS.MOUSE_OUT, mouseEventHandler);
|
||||
editor.addEventListener(editor.EVENTS.MOUSE_OVER, mouseEventHandler);
|
||||
|
||||
let target = editor.editorElement;
|
||||
let targetWin = testWin;
|
||||
|
||||
EventUtils.synthesizeMouse(target, mousePos.x, mousePos.y,
|
||||
{type: "mousemove"}, targetWin);
|
||||
EventUtils.synthesizeMouse(target, mousePos.x, mousePos.y,
|
||||
{type: "mouseout"}, targetWin);
|
||||
EventUtils.synthesizeMouse(target, mousePos.x, mousePos.y,
|
||||
{type: "mouseover"}, targetWin);
|
||||
}
|
||||
|
||||
function checkValue(aValue, aExpectedValue)
|
||||
{
|
||||
let result = Math.abs(aValue - aExpectedValue) <= maxDiff;
|
||||
if (!result) {
|
||||
info("checkValue() given " + aValue + " expected " + aExpectedValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function testPage1(aEvent)
|
||||
{
|
||||
let {event: { clientX: clientX, clientY: clientY }, x: x, y: y} = aEvent;
|
||||
|
||||
info("testPage1 " + aEvent.type +
|
||||
" clientX " + clientX + " clientY " + clientY +
|
||||
" x " + x + " y " + y);
|
||||
|
||||
// x and y are in document coordinates.
|
||||
// clientX and clientY are in view coordinates.
|
||||
// since we are scrolled at the top, both are expected to be approximately
|
||||
// the same.
|
||||
ok(checkValue(x, mousePos.x), "x is in range");
|
||||
ok(checkValue(y, mousePos.y), "y is in range");
|
||||
|
||||
ok(checkValue(clientX, mousePos.x), "clientX is in range");
|
||||
ok(checkValue(clientY, mousePos.y), "clientY is in range");
|
||||
|
||||
// we give document-relative coordinates here.
|
||||
let offset = editor.getOffsetAtLocation(x, y);
|
||||
ok(checkValue(offset, expectedOffset), "character offset is correct");
|
||||
|
||||
let rect = {x: x, y: y};
|
||||
let viewCoords = editor.convertCoordinates(rect, "document", "view");
|
||||
ok(checkValue(viewCoords.x, clientX), "viewCoords.x is in range");
|
||||
ok(checkValue(viewCoords.y, clientY), "viewCoords.y is in range");
|
||||
|
||||
rect = {x: clientX, y: clientY};
|
||||
let docCoords = editor.convertCoordinates(rect, "view", "document");
|
||||
ok(checkValue(docCoords.x, x), "docCoords.x is in range");
|
||||
ok(checkValue(docCoords.y, y), "docCoords.y is in range");
|
||||
|
||||
// we are given document-relative coordinates.
|
||||
let offsetPos = editor.getLocationAtOffset(expectedOffset);
|
||||
ok(checkValue(offsetPos.x, x), "offsetPos.x is in range");
|
||||
ok(checkValue(offsetPos.y, y), "offsetPos.y is in range");
|
||||
|
||||
// Scroll the view and test again.
|
||||
let topIndex = Math.round(editor.getLineCount() / 2);
|
||||
editor.setTopIndex(topIndex);
|
||||
expectedOffset += editor.getLineStart(topIndex);
|
||||
|
||||
executeSoon(doMouseMove.bind(null, testPage2));
|
||||
}
|
||||
|
||||
function testPage2(aEvent)
|
||||
{
|
||||
let {event: { clientX: clientX, clientY: clientY }, x: x, y: y} = aEvent;
|
||||
|
||||
info("testPage2 " + aEvent.type +
|
||||
" clientX " + clientX + " clientY " + clientY +
|
||||
" x " + x + " y " + y);
|
||||
|
||||
// after page scroll document coordinates need to be different from view
|
||||
// coordinates.
|
||||
ok(checkValue(x, mousePos.x), "x is not different from clientX");
|
||||
ok(!checkValue(y, mousePos.y), "y is different from clientY");
|
||||
|
||||
ok(checkValue(clientX, mousePos.x), "clientX is in range");
|
||||
ok(checkValue(clientY, mousePos.y), "clientY is in range");
|
||||
|
||||
// we give document-relative coordinates here.
|
||||
let offset = editor.getOffsetAtLocation(x, y);
|
||||
ok(checkValue(offset, expectedOffset), "character offset is correct");
|
||||
|
||||
let rect = {x: x, y: y};
|
||||
let viewCoords = editor.convertCoordinates(rect, "document", "view");
|
||||
ok(checkValue(viewCoords.x, clientX), "viewCoords.x is in range");
|
||||
ok(checkValue(viewCoords.y, clientY), "viewCoords.y is in range");
|
||||
|
||||
rect = {x: clientX, y: clientY};
|
||||
let docCoords = editor.convertCoordinates(rect, "view", "document");
|
||||
ok(checkValue(docCoords.x, x), "docCoords.x is in range");
|
||||
ok(checkValue(docCoords.y, y), "docCoords.y is in range");
|
||||
|
||||
// we are given document-relative coordinates.
|
||||
let offsetPos = editor.getLocationAtOffset(expectedOffset);
|
||||
ok(checkValue(offsetPos.x, x), "offsetPos.x is in range");
|
||||
ok(checkValue(offsetPos.y, y), "offsetPos.y is in range");
|
||||
|
||||
executeSoon(testEnd);
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
}
|
||||
if (testWin) {
|
||||
testWin.close();
|
||||
}
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
|
||||
openSourceEditorWindow(editorLoaded);
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 725430' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {showLineNumbers: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
let text = "firstline\nsecondline\nthirdline\nfourthline";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.JAVASCRIPT);
|
||||
editor.setText(text)
|
||||
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), "//" + text, "JS Single line Commenting Works");
|
||||
editor.undo();
|
||||
is(editor.getText(), text, "Undo Single Line Commenting action works");
|
||||
editor.redo();
|
||||
is(editor.getText(), "//" + text, "Redo works");
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "JS Single Line Uncommenting works");
|
||||
|
||||
editor.setText(text);
|
||||
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), "/*" + text + "*/", "JS Block Commenting works");
|
||||
editor.undo();
|
||||
is(editor.getText(), text, "Undo Block Commenting action works");
|
||||
editor.redo();
|
||||
is(editor.getText(), "/*" + text + "*/", "Redo works");
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "JS Block Uncommenting works");
|
||||
editor.undo();
|
||||
is(editor.getText(), "/*" + text + "*/", "Undo Block Uncommenting works");
|
||||
editor.redo();
|
||||
is(editor.getText(), text, "Redo works");
|
||||
|
||||
let regText = "//firstline\n // secondline\nthird//line\n//fourthline";
|
||||
let expText = "firstline\n secondline\nthird//line\nfourthline";
|
||||
editor.setText(regText);
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), expText, "JS Multiple Line Uncommenting works");
|
||||
editor.undo();
|
||||
is(editor.getText(), regText, "Undo Multiple Line Uncommenting works");
|
||||
editor.redo();
|
||||
is(editor.getText(), expText, "Redo works");
|
||||
|
||||
editor.setMode(SourceEditor.MODES.CSS);
|
||||
editor.setText(text);
|
||||
|
||||
expText = "/*firstline*/\nsecondline\nthirdline\nfourthline";
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), expText, "CSS Commenting without selection works");
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "CSS Uncommenting without selection works");
|
||||
|
||||
editor.setText(text);
|
||||
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), "/*" + text + "*/", "CSS Multiple Line Commenting works");
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "CSS Multiple Line Uncommenting works");
|
||||
|
||||
editor.setMode(SourceEditor.MODES.HTML);
|
||||
editor.setText(text);
|
||||
|
||||
expText = "<!--firstline-->\nsecondline\nthirdline\nfourthline";
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), expText, "HTML Commenting without selection works");
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "HTML Uncommenting without selection works");
|
||||
|
||||
editor.setText(text);
|
||||
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), "<!--" + text + "-->", "HTML Multiple Line Commenting works");
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "HTML Multiple Line Uncommenting works");
|
||||
|
||||
editor.setMode(SourceEditor.MODES.TEXT);
|
||||
editor.setText(text);
|
||||
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "Commenting disabled in Text mode");
|
||||
editor.setText(regText);
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), regText, "Uncommenting disabled in Text mode");
|
||||
|
||||
editor.setText(text);
|
||||
editor.readOnly = true;
|
||||
|
||||
editor.setCaretPosition(0);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), text, "Commenting disabled in ReadOnly mode");
|
||||
editor.setText(regText);
|
||||
EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
|
||||
EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
|
||||
is(editor.getText(), regText, "Uncommenting disabled in ReadOnly mode");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let editor;
|
||||
let testWin;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 725618 - moveLines shortcut' width='300' height='500'>" +
|
||||
"<box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
let text = "target\nfoo\nbar"
|
||||
let config = {
|
||||
initialText: text,
|
||||
};
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, config, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
let modifiers = {altKey: true, ctrlKey: Services.appinfo.OS == "Darwin"};
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", modifiers, testWin);
|
||||
is(editor.getText(), "foo\ntarget\nbar", "Move lines down works");
|
||||
is(editor.getSelectedText(), "target\n", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", modifiers, testWin);
|
||||
is(editor.getText(), "foo\nbar\ntarget", "Move lines down works");
|
||||
is(editor.getSelectedText(), "target", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", modifiers, testWin);
|
||||
is(editor.getText(), "foo\nbar\ntarget", "Check for bottom of editor works");
|
||||
is(editor.getSelectedText(), "target", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", modifiers, testWin);
|
||||
is(editor.getText(), "foo\ntarget\nbar", "Move lines up works");
|
||||
is(editor.getSelectedText(), "target\n", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", modifiers, testWin);
|
||||
is(editor.getText(), "target\nfoo\nbar", "Move lines up works");
|
||||
is(editor.getSelectedText(), "target\n", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", modifiers, testWin);
|
||||
is(editor.getText(), "target\nfoo\nbar", "Check for top of editor works");
|
||||
is(editor.getSelectedText(), "target\n", "selection is correct");
|
||||
|
||||
editor.setSelection(0, 10);
|
||||
info("text within selection =" + editor.getSelectedText());
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", modifiers, testWin);
|
||||
is(editor.getText(), "bar\ntarget\nfoo", "Multiple line move down works");
|
||||
is(editor.getSelectedText(), "target\nfoo", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", modifiers, testWin);
|
||||
is(editor.getText(), "bar\ntarget\nfoo",
|
||||
"Check for bottom of editor works with multiple line selection");
|
||||
is(editor.getSelectedText(), "target\nfoo", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", modifiers, testWin);
|
||||
is(editor.getText(), "target\nfoo\nbar", "Multiple line move up works");
|
||||
is(editor.getSelectedText(), "target\nfoo\n", "selection is correct");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", modifiers, testWin);
|
||||
is(editor.getText(), "target\nfoo\nbar",
|
||||
"Check for top of editor works with multiple line selection");
|
||||
is(editor.getSelectedText(), "target\nfoo\n", "selection is correct");
|
||||
|
||||
editor.readOnly = true;
|
||||
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", modifiers, testWin);
|
||||
is(editor.getText(), "target\nfoo\nbar",
|
||||
"Check for readOnly mode works with move lines up");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", modifiers, testWin);
|
||||
is(editor.getText(), "target\nfoo\nbar",
|
||||
"Check for readOnly mode works with move lines down");
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
registerCleanupFunction(function()
|
||||
{
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
});
|
|
@ -1,99 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let editor;
|
||||
const VERTICAL_OFFSET = 3;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 729480 - allow setCaretPosition align the target line" +
|
||||
" vertically in view according to a third argument'" +
|
||||
" width='300' height='300'><box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let box = testWin.document.querySelector("box");
|
||||
|
||||
editor = new SourceEditor();
|
||||
editor.init(box, {showLineNumbers: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
// setting 3 pages of lines containing the line number.
|
||||
let view = editor._view;
|
||||
|
||||
let lineHeight = view.getLineHeight();
|
||||
let editorHeight = view.getClientArea().height;
|
||||
let linesPerPage = Math.floor(editorHeight / lineHeight);
|
||||
let totalLines = 3 * linesPerPage;
|
||||
|
||||
let text = "";
|
||||
for (let i = 0; i < totalLines; i++) {
|
||||
text += "Line " + i + "\n";
|
||||
}
|
||||
|
||||
editor.setText(text);
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
let offset = Math.min(Math.round(linesPerPage/2), VERTICAL_OFFSET);
|
||||
// Building the iterator array.
|
||||
// [line, alignment, topIndex_check]
|
||||
let iterateOn = [
|
||||
[0, "TOP", 0],
|
||||
[25, "TOP", 25 - offset],
|
||||
// Case when the target line is already in view.
|
||||
[27, "TOP", 25 - offset],
|
||||
[0, "BOTTOM", 0],
|
||||
[5, "BOTTOM", 0],
|
||||
[38, "BOTTOM", 38 - linesPerPage + offset],
|
||||
[0, "CENTER", 0],
|
||||
[4, "CENTER", 0],
|
||||
[34, "CENTER", 34 - Math.round(linesPerPage/2)]
|
||||
];
|
||||
|
||||
function testEnd() {
|
||||
editor.destroy();
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
|
||||
function testPosition(pos) {
|
||||
is(editor.getTopIndex(), iterateOn[pos][2], "scroll is correct for test #" + pos);
|
||||
iterator(++pos);
|
||||
}
|
||||
|
||||
function iterator(i) {
|
||||
if (i == iterateOn.length) {
|
||||
testEnd();
|
||||
} else {
|
||||
editor.setCaretPosition(iterateOn[i][0], 0,
|
||||
editor.VERTICAL_ALIGN[iterateOn[i][1]]);
|
||||
executeSoon(testPosition.bind(this, i));
|
||||
}
|
||||
}
|
||||
iterator(0);
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 729960' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {showLineNumbers: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
let JSText = "function foo(aVar) {\n" +
|
||||
" // Block Level 1\n\n" +
|
||||
" function level2() {\n" +
|
||||
" let baz = aVar;\n" +
|
||||
" // Block Level 2\n" +
|
||||
" function level3() {\n" +
|
||||
" // Block Level 3\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" // Block Level 1" +
|
||||
" function bar() { /* Block Level 2 */ }\n" +
|
||||
"}";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.JAVASCRIPT);
|
||||
editor.setText(JSText);
|
||||
|
||||
// Setting caret at Line 1 bracket start.
|
||||
editor.setCaretOffset(19);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 220,
|
||||
"JS : Jump to closing bracket of the code block when caret at block start");
|
||||
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 20,
|
||||
"JS : Jump to opening bracket of the code block when caret at block end");
|
||||
|
||||
// Setting caret at Line 10 start.
|
||||
editor.setCaretOffset(161);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 20,
|
||||
"JS : Jump to opening bracket of code block when inside the function");
|
||||
|
||||
editor.setCaretOffset(161);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 220,
|
||||
"JS : Jump to closing bracket of code block when inside the function");
|
||||
|
||||
// Setting caret at Line 6 start.
|
||||
editor.setCaretOffset(67);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 159,
|
||||
"JS : Jump to closing bracket in a nested function with caret inside");
|
||||
|
||||
editor.setCaretOffset(67);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 62,
|
||||
"JS : Jump to opening bracket in a nested function with caret inside");
|
||||
|
||||
let CSSText = "#object {\n" +
|
||||
" property: value;\n" +
|
||||
" /* comment */\n" +
|
||||
"}";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.CSS);
|
||||
editor.setText(CSSText);
|
||||
|
||||
// Setting caret at Line 1 bracket start.
|
||||
editor.setCaretOffset(8);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 45,
|
||||
"CSS : Jump to closing bracket of the code block when caret at block start");
|
||||
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 9,
|
||||
"CSS : Jump to opening bracket of the code block when caret at block end");
|
||||
|
||||
// Setting caret at Line 3 start.
|
||||
editor.setCaretOffset(28);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 9,
|
||||
"CSS : Jump to opening bracket of code block when inside the function");
|
||||
|
||||
editor.setCaretOffset(28);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 45,
|
||||
"CSS : Jump to closing bracket of code block when inside the function");
|
||||
|
||||
let HTMLText = "<html>\n" +
|
||||
" <head>\n" +
|
||||
" <title>Testing Block Jump</title>\n" +
|
||||
" </head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.HTML);
|
||||
editor.setText(HTMLText);
|
||||
|
||||
// Setting caret at Line 1 end.
|
||||
editor.setCaretOffset(6);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 6,
|
||||
"HTML : Jump to block end : Nothing happens in html mode");
|
||||
|
||||
// Setting caret at Line 4 end.
|
||||
editor.setCaretOffset(64);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 64,
|
||||
"HTML : Jump to block start : Nothing happens in html mode");
|
||||
|
||||
let text = "line 1\n" +
|
||||
"line 2\n" +
|
||||
"line 3\n" +
|
||||
"line 4\n";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.TEXT);
|
||||
editor.setText(text);
|
||||
|
||||
// Setting caret at Line 1 start.
|
||||
editor.setCaretOffset(0);
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 0,
|
||||
"Text : Jump to block end : Nothing happens in text mode");
|
||||
|
||||
// Setting caret at Line 4 end.
|
||||
editor.setCaretOffset(28);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 28,
|
||||
"Text : Jump to block start : Nothing happens in text mode");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 731721' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {showAnnotationRuler: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
|
||||
editor.setText("line1\nline2\nline3\nline4");
|
||||
|
||||
is(editor.getDebugLocation(), -1, "no debugger location");
|
||||
|
||||
editor.setDebugLocation(1);
|
||||
is(editor.getDebugLocation(), 1, "set debugger location works");
|
||||
|
||||
editor.setDebugLocation(3);
|
||||
is(editor.getDebugLocation(), 3, "change debugger location works");
|
||||
|
||||
editor.setDebugLocation(-1);
|
||||
is(editor.getDebugLocation(), -1, "clear debugger location works");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
|
||||
let temp = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", temp);
|
||||
let SourceEditor = temp.SourceEditor;
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let editor;
|
||||
|
||||
const windowUrl = "data:text/xml;charset=utf8,<?xml version='1.0'?><window " +
|
||||
"xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' " +
|
||||
"title='test for bug 744021' width='600' height='500'><hbox flex='1'/>" +
|
||||
"</window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable," +
|
||||
"dialog=no";
|
||||
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank",
|
||||
windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let hbox = testWin.document.querySelector("hbox");
|
||||
editor = new SourceEditor();
|
||||
editor.init(hbox, {showLineNumbers: true}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
let JSText = "function foo() {\n" +
|
||||
" \n" +
|
||||
" function level2() {\n" +
|
||||
" \n" +
|
||||
" function level3() {\n" +
|
||||
" \n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" function bar() { /* Block Level 2 */ }\n" +
|
||||
"}\n" +
|
||||
"function baz() {\n" +
|
||||
" \n" +
|
||||
"}";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.JAVASCRIPT);
|
||||
editor.setText(JSText);
|
||||
|
||||
// Setting caret at end of line 11 (function baz() {).
|
||||
editor.setCaretOffset(147);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 16,
|
||||
"JS : Jump to opening bracket of previous sibling block when no parent");
|
||||
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 129,
|
||||
"JS : Jump to closing bracket of same code block");
|
||||
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 151,
|
||||
"JS : Jump to closing bracket of next sibling code block");
|
||||
|
||||
let CSSText = "#object1 {\n" +
|
||||
" property: value;\n" +
|
||||
" /* comment */\n" +
|
||||
"}\n" +
|
||||
".class1 {\n" +
|
||||
" property: value;\n" +
|
||||
"}";
|
||||
|
||||
editor.setMode(SourceEditor.MODES.CSS);
|
||||
editor.setText(CSSText);
|
||||
|
||||
// Setting caret at Line 5 end (.class1 {).
|
||||
editor.setCaretOffset(57);
|
||||
EventUtils.synthesizeKey("[", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 10,
|
||||
"CSS : Jump to opening bracket of previous sibling code block");
|
||||
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 46,
|
||||
"CSS : Jump to closing bracket of same code block");
|
||||
|
||||
EventUtils.synthesizeKey("]", {accelKey: true, altKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 77,
|
||||
"CSS : Jump to closing bracket of next sibling code block");
|
||||
|
||||
editor.destroy();
|
||||
|
||||
testWin.close();
|
||||
testWin = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
setup((ed, win) => {
|
||||
// appendTo
|
||||
let src = win.document.querySelector("iframe").getAttribute("src");
|
||||
ok(~src.indexOf(".CodeMirror"), "correct iframe is there");
|
||||
|
||||
// Language modes
|
||||
is(ed.getMode(), Editor.modes.text, "getMode");
|
||||
ed.setMode(Editor.modes.js);
|
||||
is(ed.getMode(), Editor.modes.js, "setMode");
|
||||
|
||||
// Content
|
||||
is(ed.getText(), "Hello.", "getText");
|
||||
ed.setText("Hi.\nHow are you?");
|
||||
is(ed.getText(), "Hi.\nHow are you?", "setText");
|
||||
is(ed.getText(1), "How are you?", "getText(num)");
|
||||
is(ed.getText(5), "", "getText(num) when num is out of scope");
|
||||
|
||||
ed.replaceText("YOU", { line: 1, ch: 8 }, { line: 1, ch: 11 });
|
||||
is(ed.getText(1), "How are YOU?", "replaceText(str, from, to)");
|
||||
ed.replaceText("you?", { line: 1, ch: 8 });
|
||||
is(ed.getText(1), "How are you?", "replaceText(str, from)");
|
||||
ed.replaceText("Hello.");
|
||||
is(ed.getText(), "Hello.", "replaceText(str)");
|
||||
|
||||
ed.insertText(", sir/madam", { line: 0, ch: 5});
|
||||
is(ed.getText(), "Hello, sir/madam.", "insertText");
|
||||
|
||||
// Add-ons
|
||||
ed.extend({ whoami: () => "Anton", whereami: () => "Mozilla" });
|
||||
is(ed.whoami(), "Anton", "extend/1");
|
||||
is(ed.whereami(), "Mozilla", "extend/2");
|
||||
|
||||
// Line classes
|
||||
ed.setText("Hello!\nHow are you?");
|
||||
ok(!ed.hasLineClass(0, "test"), "no test line class");
|
||||
ed.addLineClass(0, "test");
|
||||
ok(ed.hasLineClass(0, "test"), "test line class is there");
|
||||
ed.removeLineClass(0, "test");
|
||||
ok(!ed.hasLineClass(0, "test"), "test line class is gone");
|
||||
|
||||
teardown(ed, win);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
setup((ed, win) => {
|
||||
ch(ed.getCursor(), { line: 0, ch: 0 }, "default cursor position is ok");
|
||||
ed.setText("Hello.\nHow are you?");
|
||||
|
||||
ed.setCursor({ line: 1, ch: 5 });
|
||||
ch(ed.getCursor(), { line: 1, ch: 5 }, "setCursor({ line, ch })");
|
||||
|
||||
ch(ed.getPosition(7), { line: 1, ch: 0}, "getPosition(num)");
|
||||
ch(ed.getPosition(7, 1)[0], { line: 1, ch: 0}, "getPosition(num, num)[0]");
|
||||
ch(ed.getPosition(7, 1)[1], { line: 0, ch: 1}, "getPosition(num, num)[1]");
|
||||
|
||||
ch(ed.getOffset({ line: 1, ch: 0 }), 7, "getOffset(num)");
|
||||
ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 7, "getOffset(num, num)[0]");
|
||||
ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 2, "getOffset(num, num)[1]");
|
||||
|
||||
is(ed.getSelection(), "", "nothing is selected");
|
||||
ed.setSelection({ line: 0, ch: 0 }, { line: 0, ch: 5 });
|
||||
is(ed.getSelection(), "Hello", "setSelection");
|
||||
|
||||
ed.extendSelection({ start: 0, length: 5 });
|
||||
is(ed.getSelection(), ".\nHow", "extendSelection");
|
||||
|
||||
ed.dropSelection();
|
||||
is(ed.getSelection(), "", "dropSelection");
|
||||
|
||||
teardown(ed, win);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
setup((ed, win) => {
|
||||
ok(ed.isClean(), "default isClean");
|
||||
ok(!ed.canUndo(), "default canUndo");
|
||||
ok(!ed.canRedo(), "default canRedo");
|
||||
|
||||
ed.setText("Hello, World!");
|
||||
ok(!ed.isClean(), "isClean");
|
||||
ok(ed.canUndo(), "canUndo");
|
||||
ok(!ed.canRedo(), "canRedo");
|
||||
|
||||
ed.undo();
|
||||
ok(ed.isClean(), "isClean after undo");
|
||||
ok(!ed.canUndo(), "canUndo after undo");
|
||||
ok(ed.canRedo(), "canRedo after undo");
|
||||
|
||||
ed.setText("What's up?");
|
||||
ed.setClean();
|
||||
ok(ed.isClean(), "isClean after setClean");
|
||||
ok(ed.canUndo(), "canUndo after setClean");
|
||||
ok(!ed.canRedo(), "canRedo after setClean");
|
||||
|
||||
teardown(ed, win);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
setup((ed, win) => {
|
||||
ok(!ed.hasMarker(0, "breakpoints", "test"), "default is ok");
|
||||
ed.addMarker(0, "breakpoints", "test");
|
||||
ed.addMarker(0, "breakpoints", "test2");
|
||||
ok(ed.hasMarker(0, "breakpoints", "test"), "addMarker/1");
|
||||
ok(ed.hasMarker(0, "breakpoints", "test2"), "addMarker/2");
|
||||
|
||||
ed.removeMarker(0, "breakpoints", "test");
|
||||
ok(!ed.hasMarker(0, "breakpoints", "test"), "removeMarker/1");
|
||||
ok(ed.hasMarker(0, "breakpoints", "test2"), "removeMarker/2");
|
||||
|
||||
ed.removeAllMarkers("breakpoints");
|
||||
ok(!ed.hasMarker(0, "breakpoints", "test"), "removeAllMarkers/1");
|
||||
ok(!ed.hasMarker(0, "breakpoints", "test2"), "removeAllMarkers/2");
|
||||
|
||||
ed.addMarker(0, "breakpoints", "breakpoint");
|
||||
ed.setMarkerListeners(0, "breakpoints", "breakpoint", {
|
||||
"click": (line, marker, param) => {
|
||||
is(line, 0, "line is ok");
|
||||
is(marker.className, "breakpoint", "marker is ok");
|
||||
ok(param, "click is ok");
|
||||
|
||||
teardown(ed, win);
|
||||
}
|
||||
}, [ true ]);
|
||||
|
||||
const env = win.document.querySelector("iframe").contentWindow;
|
||||
const div = env.document.querySelector("div.breakpoint");
|
||||
div.click();
|
||||
});
|
||||
}
|
|
@ -1,499 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
let SourceEditor = tempScope.SourceEditor;
|
||||
|
||||
let testWin;
|
||||
let testDoc;
|
||||
let editor;
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
|
||||
const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='test for bug 660784' width='600' height='500'><hbox flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
testDoc = testWin.document;
|
||||
|
||||
let hbox = testDoc.querySelector("hbox");
|
||||
|
||||
editor = new SourceEditor();
|
||||
let config = {
|
||||
showLineNumbers: true,
|
||||
initialText: "foobarbaz",
|
||||
tabSize: 7,
|
||||
expandTab: true,
|
||||
};
|
||||
|
||||
editor.init(hbox, config, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
ok(editor.editorElement, "editor loaded");
|
||||
|
||||
is(editor.parentElement, testDoc.querySelector("hbox"),
|
||||
"parentElement is correct");
|
||||
|
||||
editor.focus();
|
||||
|
||||
is(editor.getMode(), SourceEditor.DEFAULTS.mode, "default editor mode");
|
||||
|
||||
// Test general editing methods.
|
||||
|
||||
ok(!editor.canUndo(), "canUndo() works (nothing to undo), just loaded");
|
||||
|
||||
ok(!editor.readOnly, "editor is not read-only");
|
||||
|
||||
is(editor.getText(), "foobarbaz", "placeholderText works");
|
||||
|
||||
is(editor.getText().length, editor.getCharCount(),
|
||||
"getCharCount() is correct");
|
||||
|
||||
is(editor.getText(3, 5), "ba", "getText() range works");
|
||||
|
||||
editor.setText("source-editor");
|
||||
|
||||
is(editor.getText(), "source-editor", "setText() works");
|
||||
|
||||
editor.setText("code", 0, 6);
|
||||
|
||||
is(editor.getText(), "code-editor", "setText() range works");
|
||||
|
||||
ok(editor.canUndo(), "canUndo() works (things to undo)");
|
||||
ok(!editor.canRedo(), "canRedo() works (nothing to redo yet)");
|
||||
|
||||
editor.undo();
|
||||
|
||||
is(editor.getText(), "source-editor", "undo() works");
|
||||
|
||||
ok(editor.canRedo(), "canRedo() works (things to redo)");
|
||||
|
||||
editor.redo();
|
||||
|
||||
is(editor.getText(), "code-editor", "redo() works");
|
||||
|
||||
EventUtils.synthesizeKey("VK_Z", {accelKey: true}, testWin);
|
||||
|
||||
is(editor.getText(), "source-editor", "Ctrl-Z (undo) works");
|
||||
|
||||
EventUtils.synthesizeKey("VK_Z", {accelKey: true, shiftKey: true}, testWin);
|
||||
|
||||
is(editor.getText(), "code-editor", "Ctrl-Shift-Z (redo) works");
|
||||
|
||||
editor.undo();
|
||||
|
||||
EventUtils.synthesizeKey("VK_Y", {accelKey: true}, testWin);
|
||||
if (Services.appinfo.OS == "WINNT" ||
|
||||
Services.appinfo.OS == "Linux") {
|
||||
is(editor.getText(), "code-editor",
|
||||
"CTRL+Y does redo on Linux and Windows");
|
||||
} else {
|
||||
is(editor.getText(), "source-editor",
|
||||
"CTRL+Y doesn't redo on machines other than Linux and Windows");
|
||||
editor.setText("code-editor");
|
||||
}
|
||||
|
||||
// Test selection methods.
|
||||
|
||||
editor.setSelection(0, 4);
|
||||
|
||||
is(editor.getSelectedText(), "code", "getSelectedText() works");
|
||||
|
||||
let selection = editor.getSelection();
|
||||
ok(selection.start == 0 && selection.end == 4, "getSelection() works");
|
||||
|
||||
editor.dropSelection();
|
||||
|
||||
selection = editor.getSelection();
|
||||
ok(selection.start == 4 && selection.end == 4, "dropSelection() works");
|
||||
|
||||
editor.setCaretOffset(7);
|
||||
is(editor.getCaretOffset(), 7, "setCaretOffset() works");
|
||||
|
||||
// Test grouped changes.
|
||||
|
||||
editor.setText("foobar");
|
||||
|
||||
editor.startCompoundChange();
|
||||
|
||||
editor.setText("foo1");
|
||||
editor.setText("foo2");
|
||||
editor.setText("foo3");
|
||||
|
||||
editor.endCompoundChange();
|
||||
|
||||
is(editor.getText(), "foo3", "editor content is correct");
|
||||
|
||||
editor.undo();
|
||||
is(editor.getText(), "foobar", "compound change undo() works");
|
||||
|
||||
editor.redo();
|
||||
is(editor.getText(), "foo3", "compound change redo() works");
|
||||
|
||||
// Minimal keyboard usage tests.
|
||||
|
||||
ok(editor.hasFocus(), "editor has focus");
|
||||
|
||||
editor.setText("code-editor");
|
||||
editor.setCaretOffset(7);
|
||||
EventUtils.synthesizeKey(".", {}, testWin);
|
||||
|
||||
is(editor.getText(), "code-ed.itor", "focus() and typing works");
|
||||
|
||||
EventUtils.synthesizeKey("a", {}, testWin);
|
||||
|
||||
is(editor.getText(), "code-ed.aitor", "typing works");
|
||||
|
||||
is(editor.getCaretOffset(), 9, "caret moved");
|
||||
|
||||
EventUtils.synthesizeKey("VK_LEFT", {}, testWin);
|
||||
|
||||
is(editor.getCaretOffset(), 8, "caret moved to the left");
|
||||
|
||||
EventUtils.synthesizeKey(".", {}, testWin);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, testWin);
|
||||
|
||||
is(editor.getText(), "code-ed.. aitor", "Tab works");
|
||||
|
||||
is(editor.getCaretOffset(), 14, "caret location is correct");
|
||||
|
||||
// Test the Tab key.
|
||||
|
||||
editor.setText("a\n b\n c");
|
||||
editor.setCaretOffset(0);
|
||||
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, testWin);
|
||||
is(editor.getText(), " a\n b\n c", "Tab works");
|
||||
|
||||
// Code editor specific tests. These are not applicable when the textarea
|
||||
// fallback is used.
|
||||
let component = Services.prefs.getCharPref(SourceEditor.PREFS.COMPONENT);
|
||||
if (component != "textarea") {
|
||||
editor.setMode(SourceEditor.MODES.JAVASCRIPT);
|
||||
is(editor.getMode(), SourceEditor.MODES.JAVASCRIPT, "setMode() works");
|
||||
|
||||
editor.setSelection(0, editor.getCharCount() - 1);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, testWin);
|
||||
is(editor.getText(), " a\n b\n c", "lines indented");
|
||||
|
||||
EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}, testWin);
|
||||
is(editor.getText(), " a\n b\n c", "lines outdented (shift-tab)");
|
||||
|
||||
testEclipseBug362107();
|
||||
testBug687577();
|
||||
testBackspaceKey();
|
||||
testReturnKey();
|
||||
}
|
||||
|
||||
// Test the read-only mode.
|
||||
|
||||
editor.setText("foofoo");
|
||||
|
||||
editor.readOnly = true;
|
||||
EventUtils.synthesizeKey("b", {}, testWin);
|
||||
is(editor.getText(), "foofoo", "editor is now read-only (keyboard)");
|
||||
|
||||
editor.setText("foobar");
|
||||
is(editor.getText(), "foobar", "editor allows programmatic changes (setText)");
|
||||
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, testWin);
|
||||
is(editor.getText(), "foobar", "Enter key does nothing");
|
||||
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, testWin);
|
||||
is(editor.getText(), "foobar", "Tab does nothing");
|
||||
|
||||
editor.setText(" foobar");
|
||||
EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}, testWin);
|
||||
is(editor.getText(), " foobar", "Shift+Tab does nothing");
|
||||
|
||||
editor.readOnly = false;
|
||||
|
||||
editor.setCaretOffset(editor.getCharCount());
|
||||
EventUtils.synthesizeKey("-", {}, testWin);
|
||||
is(editor.getText(), " foobar-", "editor is now editable again");
|
||||
|
||||
// Test the Selection event.
|
||||
|
||||
editor.setText("foobarbaz");
|
||||
|
||||
editor.setSelection(1, 4);
|
||||
|
||||
let event = null;
|
||||
|
||||
let eventHandler = function(aEvent) {
|
||||
event = aEvent;
|
||||
};
|
||||
editor.addEventListener(SourceEditor.EVENTS.SELECTION, eventHandler);
|
||||
|
||||
editor.setSelection(0, 3);
|
||||
|
||||
ok(event, "selection event fired");
|
||||
ok(event.oldValue.start == 1 && event.oldValue.end == 4,
|
||||
"event.oldValue is correct");
|
||||
ok(event.newValue.start == 0 && event.newValue.end == 3,
|
||||
"event.newValue is correct");
|
||||
|
||||
event = null;
|
||||
editor.dropSelection();
|
||||
|
||||
ok(event, "selection dropped");
|
||||
ok(event.oldValue.start == 0 && event.oldValue.end == 3,
|
||||
"event.oldValue is correct");
|
||||
ok(event.newValue.start == 3 && event.newValue.end == 3,
|
||||
"event.newValue is correct");
|
||||
|
||||
event = null;
|
||||
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
|
||||
|
||||
ok(event, "select all worked");
|
||||
ok(event.oldValue.start == 3 && event.oldValue.end == 3,
|
||||
"event.oldValue is correct");
|
||||
ok(event.newValue.start == 0 && event.newValue.end == 9,
|
||||
"event.newValue is correct");
|
||||
|
||||
event = null;
|
||||
editor.removeEventListener(SourceEditor.EVENTS.SELECTION, eventHandler);
|
||||
editor.dropSelection();
|
||||
|
||||
ok(!event, "selection event listener removed");
|
||||
|
||||
// Test the TextChanged event.
|
||||
|
||||
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, eventHandler);
|
||||
|
||||
EventUtils.synthesizeKey(".", {}, testWin);
|
||||
|
||||
ok(event, "the TextChanged event fired after keypress");
|
||||
is(event.start, 9, "event.start is correct");
|
||||
is(event.removedCharCount, 0, "event.removedCharCount is correct");
|
||||
is(event.addedCharCount, 1, "event.addedCharCount is correct");
|
||||
|
||||
editor.setText("line1\nline2\nline3");
|
||||
let chars = editor.getText().length;
|
||||
event = null;
|
||||
|
||||
editor.setText("a\nline4\nline5", chars);
|
||||
|
||||
ok(event, "the TextChanged event fired after setText()");
|
||||
is(event.start, chars, "event.start is correct");
|
||||
is(event.removedCharCount, 0, "event.removedCharCount is correct");
|
||||
is(event.addedCharCount, 13, "event.addedCharCount is correct");
|
||||
|
||||
event = null;
|
||||
editor.setText("line3b\nline4b\nfoo", 12, 24);
|
||||
|
||||
ok(event, "the TextChanged event fired after setText() again");
|
||||
is(event.start, 12, "event.start is correct");
|
||||
is(event.removedCharCount, 12, "event.removedCharCount is correct");
|
||||
is(event.addedCharCount, 17, "event.addedCharCount is correct");
|
||||
|
||||
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, eventHandler);
|
||||
|
||||
testClipboardEvents();
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
editor.destroy();
|
||||
ok(!editor.parentElement && !editor.editorElement, "destroy() works");
|
||||
|
||||
testWin.close();
|
||||
|
||||
testWin = testDoc = editor = null;
|
||||
|
||||
waitForFocus(finish, window);
|
||||
}
|
||||
|
||||
function testBackspaceKey()
|
||||
{
|
||||
editor.setText(" a\n b\n c");
|
||||
editor.setCaretOffset(7);
|
||||
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, testWin);
|
||||
is(editor.getText(), "a\n b\n c", "line outdented (Backspace)");
|
||||
|
||||
editor.undo();
|
||||
|
||||
editor.setCaretOffset(6);
|
||||
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, testWin);
|
||||
is(editor.getText(), " a\n b\n c", "backspace one char works");
|
||||
}
|
||||
|
||||
function testReturnKey()
|
||||
{
|
||||
editor.setText(" a\n b\n c");
|
||||
|
||||
editor.setCaretOffset(8);
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, testWin);
|
||||
EventUtils.synthesizeKey("x", {}, testWin);
|
||||
|
||||
let lineDelimiter = editor.getLineDelimiter();
|
||||
ok(lineDelimiter, "we have the line delimiter");
|
||||
|
||||
let indentationString = editor.getIndentationString();
|
||||
is(" ", indentationString, "we have an indentation string of 7 spaces");
|
||||
|
||||
is(editor.getText(), " a" + lineDelimiter + " x\n b\n c",
|
||||
"return maintains indentation");
|
||||
|
||||
editor.setCaretOffset(12 + lineDelimiter.length);
|
||||
EventUtils.synthesizeKey("z", {}, testWin);
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, testWin);
|
||||
EventUtils.synthesizeKey("y", {}, testWin);
|
||||
is(editor.getText(), " a" + lineDelimiter +
|
||||
" z" + lineDelimiter + " yx\n b\n c",
|
||||
"return maintains indentation (again)");
|
||||
}
|
||||
|
||||
function testClipboardEvents()
|
||||
{
|
||||
editor.setText("foobar");
|
||||
|
||||
let doCut = function() {
|
||||
EventUtils.synthesizeKey("a", {accelKey: true}, testWin);
|
||||
|
||||
is(editor.getSelectedText(), "foobar", "select all worked");
|
||||
|
||||
EventUtils.synthesizeKey("x", {accelKey: true}, testWin);
|
||||
};
|
||||
|
||||
let onCut = function() {
|
||||
ok(!editor.getText(), "cut works");
|
||||
editor.setText("test--");
|
||||
editor.setCaretOffset(5);
|
||||
|
||||
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste1);
|
||||
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
|
||||
};
|
||||
|
||||
let onPaste1 = function() {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste1);
|
||||
|
||||
is(editor.getText(), "test-foobar-", "paste works");
|
||||
|
||||
executeSoon(waitForClipboard.bind(this, "test", doCopy, onCopy, testEnd));
|
||||
};
|
||||
|
||||
let doCopy = function() {
|
||||
editor.setSelection(0, 4);
|
||||
EventUtils.synthesizeKey("c", {accelKey: true}, testWin);
|
||||
};
|
||||
|
||||
let onCopy = function() {
|
||||
editor.setSelection(5, 11);
|
||||
editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste2);
|
||||
EventUtils.synthesizeKey("v", {accelKey: true}, testWin);
|
||||
};
|
||||
|
||||
let pasteTextChanges = 0;
|
||||
let removedCharCount = 0;
|
||||
let addedCharCount = 0;
|
||||
let onPaste2 = function(aEvent) {
|
||||
pasteTextChanges++;
|
||||
ok(aEvent && (pasteTextChanges == 1 || pasteTextChanges == 2),
|
||||
"event TEXT_CHANGED fired " + pasteTextChanges + " time(s)");
|
||||
|
||||
is(aEvent.start, 5, "event.start is correct");
|
||||
if (aEvent.removedCharCount) {
|
||||
removedCharCount = aEvent.removedCharCount;
|
||||
}
|
||||
if (aEvent.addedCharCount) {
|
||||
addedCharCount = aEvent.addedCharCount;
|
||||
}
|
||||
|
||||
if (pasteTextChanges == 2 || addedCharCount && removedCharCount) {
|
||||
editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onPaste2);
|
||||
executeSoon(checkPaste2Result);
|
||||
}
|
||||
};
|
||||
|
||||
let checkPaste2Result = function() {
|
||||
is(removedCharCount, 6, "event.removedCharCount is correct");
|
||||
is(addedCharCount, 4, "event.addedCharCount is correct");
|
||||
|
||||
is(editor.getText(), "test-test-", "paste works after copy");
|
||||
testEnd();
|
||||
};
|
||||
|
||||
waitForClipboard("foobar", doCut, onCut, testEnd);
|
||||
}
|
||||
|
||||
function testEclipseBug362107()
|
||||
{
|
||||
// Test for Eclipse Bug 362107:
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=362107
|
||||
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
|
||||
if (OS != "Linux") {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.setText("line 1\nline 2\nline 3");
|
||||
editor.setCaretOffset(16);
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 9, "Ctrl-Up works");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 2, "Ctrl-Up works twice");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 9, "Ctrl-Down works");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true}, testWin);
|
||||
is(editor.getCaretOffset(), 16, "Ctrl-Down works twice");
|
||||
}
|
||||
|
||||
function testBug687577()
|
||||
{
|
||||
// Test for Mozilla Bug 687577:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=687577
|
||||
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
|
||||
if (OS != "Linux") {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.setText("line foobar 1\nline foobar 2\nline foobar 3");
|
||||
editor.setCaretOffset(39);
|
||||
|
||||
EventUtils.synthesizeKey("VK_LEFT", {ctrlKey: true, shiftKey: true}, testWin);
|
||||
let selection = editor.getSelection();
|
||||
is(selection.start, 33, "select.start after Ctrl-Shift-Left");
|
||||
is(selection.end, 39, "select.end after Ctrl-Shift-Left");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true, shiftKey: true}, testWin);
|
||||
selection = editor.getSelection();
|
||||
is(selection.start, 14, "select.start after Ctrl-Shift-Up");
|
||||
is(selection.end, 39, "select.end after Ctrl-Shift-Up");
|
||||
|
||||
EventUtils.synthesizeKey("VK_UP", {ctrlKey: true, shiftKey: true}, testWin);
|
||||
selection = editor.getSelection();
|
||||
is(selection.start, 0, "select.start after Ctrl-Shift-Up (again)");
|
||||
is(selection.end, 39, "select.end after Ctrl-Shift-Up (again)");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true, shiftKey: true}, testWin);
|
||||
selection = editor.getSelection();
|
||||
is(selection.start, 27, "select.start after Ctrl-Shift-Down");
|
||||
is(selection.end, 39, "select.end after Ctrl-Shift-Down");
|
||||
|
||||
EventUtils.synthesizeKey("VK_DOWN", {ctrlKey: true, shiftKey: true}, testWin);
|
||||
selection = editor.getSelection();
|
||||
is(selection.start, 39, "select.start after Ctrl-Shift-Down (again)");
|
||||
is(selection.end, 41, "select.end after Ctrl-Shift-Down (again)");
|
||||
}
|
|
@ -4,179 +4,43 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
function getLoadContext() {
|
||||
return window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
}
|
||||
const require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
|
||||
const Editor = require("devtools/sourceeditor/editor");
|
||||
|
||||
/*
|
||||
* Polls the X11 primary selection buffer waiting for the expected value. A known
|
||||
* value different than the expected value is put on the clipboard first (and
|
||||
* also polled for) so we can be sure the value we get isn't just the expected
|
||||
* value because it was already in the buffer.
|
||||
*
|
||||
* @param aExpectedStringOrValidatorFn
|
||||
* The string value that is expected to be in the X11 primary selection buffer
|
||||
* or a validator function getting clipboard data and returning a bool.
|
||||
* @param aSetupFn
|
||||
* A function responsible for setting the primary selection buffer to the
|
||||
* expected value, called after the known value setting succeeds.
|
||||
* @param aSuccessFn
|
||||
* A function called when the expected value is found in the primary
|
||||
* selection buffer.
|
||||
* @param aFailureFn
|
||||
* A function called if the expected value isn't found in the primary
|
||||
* selection buffer within 5s. It can also be called if the known value
|
||||
* can't be found.
|
||||
* @param aFlavor [optional] The flavor to look for. Defaults to "text/unicode".
|
||||
*/
|
||||
function waitForSelection(aExpectedStringOrValidatorFn, aSetupFn,
|
||||
aSuccessFn, aFailureFn, aFlavor) {
|
||||
let requestedFlavor = aFlavor || "text/unicode";
|
||||
|
||||
// Build a default validator function for common string input.
|
||||
var inputValidatorFn = typeof(aExpectedStringOrValidatorFn) == "string"
|
||||
? function(aData) aData == aExpectedStringOrValidatorFn
|
||||
: aExpectedStringOrValidatorFn;
|
||||
|
||||
let clipboard = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
|
||||
// reset for the next use
|
||||
function reset() {
|
||||
waitForSelection._polls = 0;
|
||||
}
|
||||
|
||||
function wait(validatorFn, successFn, failureFn, flavor) {
|
||||
if (++waitForSelection._polls > 50) {
|
||||
// Log the failure.
|
||||
ok(false, "Timed out while polling the X11 primary selection buffer.");
|
||||
reset();
|
||||
failureFn();
|
||||
return;
|
||||
}
|
||||
|
||||
let transferable = Cc["@mozilla.org/widget/transferable;1"].
|
||||
createInstance(Ci.nsITransferable);
|
||||
transferable.init(getLoadContext());
|
||||
transferable.addDataFlavor(requestedFlavor);
|
||||
|
||||
clipboard.getData(transferable, clipboard.kSelectionClipboard);
|
||||
|
||||
let str = {};
|
||||
let strLength = {};
|
||||
|
||||
transferable.getTransferData(requestedFlavor, str, strLength);
|
||||
|
||||
let data = null;
|
||||
if (str.value) {
|
||||
let strValue = str.value.QueryInterface(Ci.nsISupportsString);
|
||||
data = strValue.data.substring(0, strLength.value / 2);
|
||||
}
|
||||
|
||||
if (validatorFn(data)) {
|
||||
// Don't show the success message when waiting for preExpectedVal
|
||||
if (preExpectedVal) {
|
||||
preExpectedVal = null;
|
||||
} else {
|
||||
ok(true, "The X11 primary selection buffer has the correct value");
|
||||
}
|
||||
reset();
|
||||
successFn();
|
||||
} else {
|
||||
setTimeout(function() wait(validatorFn, successFn, failureFn, flavor), 100);
|
||||
}
|
||||
}
|
||||
|
||||
// First we wait for a known value different from the expected one.
|
||||
var preExpectedVal = waitForSelection._monotonicCounter +
|
||||
"-waitForSelection-known-value";
|
||||
|
||||
let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].
|
||||
getService(Ci.nsIClipboardHelper);
|
||||
clipboardHelper.copyStringToClipboard(preExpectedVal,
|
||||
Ci.nsIClipboard.kSelectionClipboard,
|
||||
document);
|
||||
|
||||
wait(function(aData) aData == preExpectedVal,
|
||||
function() {
|
||||
// Call the original setup fn
|
||||
aSetupFn();
|
||||
wait(inputValidatorFn, aSuccessFn, aFailureFn, requestedFlavor);
|
||||
}, aFailureFn, "text/unicode");
|
||||
}
|
||||
|
||||
waitForSelection._polls = 0;
|
||||
waitForSelection.__monotonicCounter = 0;
|
||||
waitForSelection.__defineGetter__("_monotonicCounter", function () {
|
||||
return waitForSelection.__monotonicCounter++;
|
||||
});
|
||||
|
||||
/**
|
||||
* Open a new window with a source editor inside.
|
||||
*
|
||||
* @param function aCallback
|
||||
* The function you want invoked once the editor is loaded. The function
|
||||
* is given two arguments: editor instance and the window object.
|
||||
* @param object [aOptions]
|
||||
* The options object to pass to the SourceEditor.init() method.
|
||||
*/
|
||||
function openSourceEditorWindow(aCallback, aOptions) {
|
||||
const windowUrl = "data:text/xml;charset=UTF-8,<?xml version='1.0'?>" +
|
||||
function setup(cb) {
|
||||
const opt = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
const url = "data:text/xml;charset=UTF-8,<?xml version='1.0'?>" +
|
||||
"<?xml-stylesheet href='chrome://global/skin/global.css'?>" +
|
||||
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||
" title='Test for Source Editor' width='600' height='500'><box flex='1'/></window>";
|
||||
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
" title='Editor' width='600' height='500'><box flex='1'/></window>";
|
||||
|
||||
let editor = null;
|
||||
let testWin = Services.ww.openWindow(null, windowUrl, "_blank",
|
||||
windowFeatures, null);
|
||||
testWin.addEventListener("load", function onWindowLoad() {
|
||||
testWin.removeEventListener("load", onWindowLoad, false);
|
||||
waitForFocus(initEditor, testWin);
|
||||
let win = Services.ww.openWindow(null, url, "_blank", opt, null);
|
||||
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
|
||||
waitForFocus(function () {
|
||||
let box = win.document.querySelector("box");
|
||||
let editor = new Editor({
|
||||
value: "Hello.",
|
||||
lineNumbers: true,
|
||||
gutters: [ "breakpoints" ]
|
||||
});
|
||||
|
||||
editor.appendTo(box)
|
||||
.then(() => cb(editor, win))
|
||||
.then(null, (err) => ok(false, err.message));
|
||||
}, win);
|
||||
}, false);
|
||||
|
||||
function initEditor()
|
||||
{
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm", tempScope);
|
||||
|
||||
let box = testWin.document.querySelector("box");
|
||||
editor = new tempScope.SourceEditor();
|
||||
editor.init(box, aOptions || {}, editorLoaded);
|
||||
}
|
||||
|
||||
function editorLoaded()
|
||||
{
|
||||
editor.focus();
|
||||
waitForFocus(aCallback.bind(null, editor, testWin), testWin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text needed to fill the editor view.
|
||||
*
|
||||
* @param object aEditor
|
||||
* The SourceEditor instance you work with.
|
||||
* @param number aPages
|
||||
* The number of pages you want filled with lines.
|
||||
* @return string
|
||||
* The string you can insert into the editor so you fill the desired
|
||||
* number of pages.
|
||||
*/
|
||||
function fillEditor(aEditor, aPages) {
|
||||
let view = aEditor._view;
|
||||
let model = aEditor._model;
|
||||
|
||||
let lineHeight = view.getLineHeight();
|
||||
let editorHeight = view.getClientArea().height;
|
||||
let linesPerPage = Math.floor(editorHeight / lineHeight);
|
||||
let totalLines = aPages * linesPerPage;
|
||||
|
||||
let text = "";
|
||||
for (let i = 0; i < totalLines; i++) {
|
||||
text += "l" + i + " lorem ipsum dolor sit amet. lipsum foobaris bazbaz,\n";
|
||||
}
|
||||
|
||||
return text;
|
||||
function ch(exp, act, label) {
|
||||
is(exp.line, act.line, label + " (line)");
|
||||
is(exp.ch, act.ch, label + " (ch)");
|
||||
}
|
||||
|
||||
function teardown(ed, win) {
|
||||
ed.destroy();
|
||||
win.close();
|
||||
finish();
|
||||
}
|
|
@ -210,7 +210,8 @@ StyleSheetEditor.prototype = {
|
|||
mode: Editor.modes.css,
|
||||
readOnly: this._state.readOnly,
|
||||
autoCloseBrackets: "{}()[]",
|
||||
extraKeys: this._getKeyBindings()
|
||||
extraKeys: this._getKeyBindings(),
|
||||
contextMenu: "sourceEditorContextMenu"
|
||||
};
|
||||
let sourceEditor = new Editor(config);
|
||||
|
||||
|
@ -380,8 +381,8 @@ StyleSheetEditor.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Retrieve custom key bindings objects as expected by SourceEditor.
|
||||
* SourceEditor action names are not displayed to the user.
|
||||
* Retrieve custom key bindings objects as expected by Editor.
|
||||
* Editor action names are not displayed to the user.
|
||||
*
|
||||
* @return {array} key binding objects for the source editor
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
<!DOCTYPE window [
|
||||
<!ENTITY % styleEditorDTD SYSTEM "chrome://browser/locale/devtools/styleeditor.dtd" >
|
||||
%styleEditorDTD;
|
||||
<!ENTITY % editMenuStrings SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
|
||||
%editMenuStrings;
|
||||
<!ENTITY % sourceEditorStrings SYSTEM "chrome://browser/locale/devtools/sourceeditor.dtd">
|
||||
%sourceEditorStrings;
|
||||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/devtools/splitview.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/devtools/common.css" type="text/css"?>
|
||||
|
@ -13,7 +18,7 @@
|
|||
<?xml-stylesheet href="chrome://browser/content/devtools/styleeditor.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/devtools/styleeditor.css" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://browser/content/devtools/source-editor-overlay.xul"?>
|
||||
|
||||
<xul:window xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
id="style-editor-chrome-window">
|
||||
|
@ -21,28 +26,46 @@
|
|||
<script type="application/javascript;version=1.8"
|
||||
src="chrome://browser/content/devtools/theme-switching.js"/>
|
||||
<xul:script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<xul:script type="application/javascript">
|
||||
function goUpdateSourceEditorMenuItems() {
|
||||
goUpdateGlobalEditMenuItems();
|
||||
|
||||
['cmd_undo', 'cmd_redo', 'cmd_cut', 'cmd_paste',
|
||||
'cmd_delete', 'cmd_find', 'cmd_findAgain'].forEach(goUpdateCommand);
|
||||
}
|
||||
</xul:script>
|
||||
|
||||
<xul:popupset id="style-editor-popups">
|
||||
<xul:menupopup id="sourceEditorContextMenu"
|
||||
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||
<xul:menuitem id="se-cMenu-undo"/>
|
||||
<xul:menuitem id="cMenu_undo"/>
|
||||
<xul:menuseparator/>
|
||||
<xul:menuitem id="se-cMenu-cut"/>
|
||||
<xul:menuitem id="se-cMenu-copy"/>
|
||||
<xul:menuitem id="se-cMenu-paste"/>
|
||||
<xul:menuitem id="se-cMenu-delete"/>
|
||||
<xul:menuitem id="cMenu_cut"/>
|
||||
<xul:menuitem id="cMenu_copy"/>
|
||||
<xul:menuitem id="cMenu_paste"/>
|
||||
<xul:menuitem id="cMenu_delete"/>
|
||||
<xul:menuseparator/>
|
||||
<xul:menuitem id="se-cMenu-selectAll"/>
|
||||
<xul:menuitem id="cMenu_selectAll"/>
|
||||
<xul:menuseparator/>
|
||||
<xul:menuitem id="se-cMenu-find"/>
|
||||
<xul:menuitem id="se-cMenu-findAgain"/>
|
||||
<xul:menuitem id="se-menu-find"
|
||||
label="&findCmd.label;" accesskey="&findCmd.accesskey;" command="cmd_find"/>
|
||||
<xul:menuitem id="cMenu_findAgain"/>
|
||||
<xul:menuseparator/>
|
||||
<xul:menuitem id="se-cMenu-gotoLine"/>
|
||||
<xul:menuitem id="se-menu-gotoLine"
|
||||
label="&gotoLineCmd.label;"
|
||||
accesskey="&gotoLineCmd.accesskey;"
|
||||
key="key_gotoLine"
|
||||
command="cmd_gotoLine"/>
|
||||
</xul:menupopup>
|
||||
</xul:popupset>
|
||||
|
||||
<xul:commandset id="editMenuCommands"/>
|
||||
<xul:commandset id="sourceEditorCommands"/>
|
||||
|
||||
<xul:commandset id="sourceEditorCommands">
|
||||
<xul:command id="cmd_gotoLine" oncommand="goDoCommand('cmd_gotoLine')"/>
|
||||
<xul:command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
|
||||
<xul:command id="cmd_findAgain" oncommand="goDoCommand('cmd_findAgain')"/>
|
||||
</xul:commandset>
|
||||
|
||||
<xul:keyset id="sourceEditorKeys"/>
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ function runTests(aUI)
|
|||
|
||||
executeSoon(function () {
|
||||
is(aEditor.sourceEditor, originalSourceEditor,
|
||||
"the editor still references the same SourceEditor instance");
|
||||
"the editor still references the same Editor instance");
|
||||
let editor = aEditor.sourceEditor;
|
||||
is(editor.getOffset(editor.getCursor()), 4,
|
||||
"the caret position has been preserved");
|
||||
|
|
Двоичные данные
browser/themes/linux/devtools/orion-breakpoint.png
До Ширина: | Высота: | Размер: 577 B |
|
@ -1,39 +0,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/. */
|
||||
|
||||
.viewTooltip {
|
||||
display: none; /* TODO: add tooltips support, see bug 721752 */
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
background-color: InfoBackground;
|
||||
color: InfoText;
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid black;
|
||||
z-index: 100;
|
||||
position: fixed;
|
||||
overflow: hidden;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.viewTooltip em {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotationHTML.task {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
.annotationHTML.breakpoint {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
Двоичные данные
browser/themes/linux/devtools/orion-debug-location.png
До Ширина: | Высота: | Размер: 308 B |
Двоичные данные
browser/themes/linux/devtools/orion-error.png
До Ширина: | Высота: | Размер: 3.7 KiB |
Двоичные данные
browser/themes/linux/devtools/orion-task.png
До Ширина: | Высота: | Размер: 413 B |
|
@ -1,199 +0,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/. */
|
||||
|
||||
.viewContainer {
|
||||
background: hsl(0,0%,89%); /* This will be seen as the continuation of the ruler */
|
||||
font-family: monospace;
|
||||
font-size: inherit; /* inherit browser's default monospace font size */
|
||||
}
|
||||
|
||||
.view {
|
||||
color: black; /* Default text color */
|
||||
background: white; /* Background of the editor */
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.readonly > .view {
|
||||
background: #fdfefd; /* super light green */
|
||||
}
|
||||
|
||||
.ruler {
|
||||
background: hsl(0,0%,89%);
|
||||
color: hsl(0,0%,55%);
|
||||
}
|
||||
.ruler.annotations {
|
||||
width: 16px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
.ruler.lines {
|
||||
border-right: 1px solid #b4c4d3;
|
||||
min-width: 1.4em;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.ruler.linesWithAnnotations {
|
||||
min-width: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.ruler.overview {
|
||||
border-left: 1px solid #b4c4d3;
|
||||
width: 14px;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
/* Styles for the annotation ruler (first line) */
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotation.task .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
.annotation.breakpoint .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
||||
.annotation.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
|
||||
}
|
||||
.annotation.breakpoint.debugLocation .annotationHTML,
|
||||
.annotation.task.debugLocation .annotationHTML {
|
||||
background-position: center, center;
|
||||
background-repeat: no-repeat, no-repeat;
|
||||
background-size: 75%, 100%;
|
||||
}
|
||||
.annotation.breakpoint.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
||||
|
||||
.annotation.task.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
|
||||
/* Styles for the overview ruler */
|
||||
.annotationOverview {
|
||||
cursor: pointer;
|
||||
border-radius: 2px;
|
||||
left: 2px;
|
||||
width: 8px;
|
||||
}
|
||||
.annotationOverview.task {
|
||||
background-color: lightgreen;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.breakpoint {
|
||||
background-color: lightblue;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
.annotationOverview.debugLocation {
|
||||
background-color: white;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.currentBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
.annotationOverview.matchingBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
/* Styles for text range */
|
||||
.annotationRange {
|
||||
background-repeat: repeat-x;
|
||||
background-position: left bottom;
|
||||
}
|
||||
.annotationRange.task {
|
||||
outline: 1px dashed rgba(0, 255, 0, 0.5);
|
||||
}
|
||||
.annotationRange.matchingBracket {
|
||||
outline: 1px solid grey;
|
||||
}
|
||||
|
||||
.token_singleline_comment,
|
||||
.token_multiline_comment,
|
||||
.token_doc_comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.token_doc_html_markup {
|
||||
color: #dd0058; /* purple */
|
||||
}
|
||||
|
||||
.token_doc_tag {
|
||||
color: #dd0058; /* purple */
|
||||
}
|
||||
|
||||
.token_task_tag { /* "TODO" */
|
||||
color: black;
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.token_string {
|
||||
color: hsl(72,100%,27%); /* green */
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token_keyword {
|
||||
color: hsl(276,44%,45%); /* purple */
|
||||
}
|
||||
|
||||
.token_space {
|
||||
/* images/white_space.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
.token_tab {
|
||||
/* images/white_tab.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
.line_caret,
|
||||
.annotationLine.currentLine { /* Current line */
|
||||
background: hsl(208, 93%, 94%);
|
||||
}
|
||||
|
||||
.readonly .line_caret,
|
||||
.readonly .annotationLine.currentLine {
|
||||
background: hsl(208, 80%, 90%);
|
||||
}
|
||||
|
||||
/* Styling for html syntax highlighting */
|
||||
.entity-name-tag {
|
||||
color: hsl(208,48%,40%); /* blue */
|
||||
}
|
||||
|
||||
.entity-other-attribute-name {
|
||||
color: hsl(208,48%,40%); /* blue */
|
||||
}
|
||||
|
||||
.punctuation-definition-comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.string-quoted {
|
||||
color: hsl(24,85%,39%); /* orange */
|
||||
}
|
||||
|
||||
.invalid {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
|
@ -163,12 +163,9 @@ browser.jar:
|
|||
skin/classic/browser/devtools/webconsole.png (devtools/webconsole.png)
|
||||
skin/classic/browser/devtools/commandline.css (devtools/commandline.css)
|
||||
skin/classic/browser/devtools/markup-view.css (../shared/devtools/markup-view.css)
|
||||
skin/classic/browser/devtools/orion.css (devtools/orion.css)
|
||||
skin/classic/browser/devtools/orion-container.css (devtools/orion-container.css)
|
||||
skin/classic/browser/devtools/orion-task.png (devtools/orion-task.png)
|
||||
skin/classic/browser/devtools/orion-error.png (devtools/orion-error.png)
|
||||
skin/classic/browser/devtools/orion-breakpoint.png (devtools/orion-breakpoint.png)
|
||||
skin/classic/browser/devtools/orion-debug-location.png (devtools/orion-debug-location.png)
|
||||
skin/classic/browser/devtools/editor-error.png (devtools/editor-error.png)
|
||||
skin/classic/browser/devtools/editor-breakpoint.png (devtools/editor-breakpoint.png)
|
||||
skin/classic/browser/devtools/editor-debug-location.png (devtools/editor-debug-location.png)
|
||||
skin/classic/browser/devtools/breadcrumbs-scrollbutton.png (devtools/breadcrumbs-scrollbutton.png)
|
||||
skin/classic/browser/devtools/breadcrumbs/ltr-end-pressed.png (devtools/breadcrumbs/ltr-end-pressed.png)
|
||||
skin/classic/browser/devtools/breadcrumbs/ltr-end-selected-pressed.png (devtools/breadcrumbs/ltr-end-selected-pressed.png)
|
||||
|
|
Двоичные данные
browser/themes/osx/devtools/orion-breakpoint.png
До Ширина: | Высота: | Размер: 577 B |
|
@ -1,39 +0,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/. */
|
||||
|
||||
.viewTooltip {
|
||||
display: none; /* TODO: add tooltips support, see bug 721752 */
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
background-color: InfoBackground;
|
||||
color: InfoText;
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid black;
|
||||
z-index: 100;
|
||||
position: fixed;
|
||||
overflow: hidden;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.viewTooltip em {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotationHTML.task {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
.annotationHTML.breakpoint {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
Двоичные данные
browser/themes/osx/devtools/orion-debug-location.png
До Ширина: | Высота: | Размер: 308 B |
Двоичные данные
browser/themes/osx/devtools/orion-error.png
До Ширина: | Высота: | Размер: 3.7 KiB |
Двоичные данные
browser/themes/osx/devtools/orion-task.png
До Ширина: | Высота: | Размер: 413 B |
|
@ -1,199 +0,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/. */
|
||||
|
||||
.viewContainer {
|
||||
background: hsl(0,0%,89%); /* This will be seen as the continuation of the ruler */
|
||||
font-family: monospace;
|
||||
font-size: inherit; /* inherit browser's default monospace font size */
|
||||
}
|
||||
|
||||
.view {
|
||||
color: black; /* Default text color */
|
||||
background: white; /* Background of the editor */
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.readonly > .view {
|
||||
background: #fdfefd; /* super light green */
|
||||
}
|
||||
|
||||
.ruler {
|
||||
background: hsl(0,0%,89%);
|
||||
color: hsl(0,0%,55%);
|
||||
}
|
||||
.ruler.annotations {
|
||||
width: 16px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
.ruler.lines {
|
||||
border-right: 1px solid #b4c4d3;
|
||||
min-width: 1.4em;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.ruler.linesWithAnnotations {
|
||||
min-width: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.ruler.overview {
|
||||
border-left: 1px solid #b4c4d3;
|
||||
width: 14px;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
/* Styles for the annotation ruler (first line) */
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotation.task .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
.annotation.breakpoint .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
||||
.annotation.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
|
||||
}
|
||||
.annotation.breakpoint.debugLocation .annotationHTML,
|
||||
.annotation.task.debugLocation .annotationHTML {
|
||||
background-position: center, center;
|
||||
background-repeat: no-repeat, no-repeat;
|
||||
background-size: 75%, 100%;
|
||||
}
|
||||
.annotation.breakpoint.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
||||
|
||||
.annotation.task.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
|
||||
/* Styles for the overview ruler */
|
||||
.annotationOverview {
|
||||
cursor: pointer;
|
||||
border-radius: 2px;
|
||||
left: 2px;
|
||||
width: 8px;
|
||||
}
|
||||
.annotationOverview.task {
|
||||
background-color: lightgreen;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.breakpoint {
|
||||
background-color: lightblue;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
.annotationOverview.debugLocation {
|
||||
background-color: white;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.currentBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
.annotationOverview.matchingBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
/* Styles for text range */
|
||||
.annotationRange {
|
||||
background-repeat: repeat-x;
|
||||
background-position: left bottom;
|
||||
}
|
||||
.annotationRange.task {
|
||||
outline: 1px dashed rgba(0, 255, 0, 0.5);
|
||||
}
|
||||
.annotationRange.matchingBracket {
|
||||
outline: 1px solid grey;
|
||||
}
|
||||
|
||||
.token_singleline_comment,
|
||||
.token_multiline_comment,
|
||||
.token_doc_comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.token_doc_html_markup {
|
||||
color: #dd0058; /* purple */
|
||||
}
|
||||
|
||||
.token_doc_tag {
|
||||
color: #dd0058; /* purple */
|
||||
}
|
||||
|
||||
.token_task_tag { /* "TODO" */
|
||||
color: black;
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.token_string {
|
||||
color: hsl(72,100%,27%); /* green */
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token_keyword {
|
||||
color: hsl(276,44%,45%); /* purple */
|
||||
}
|
||||
|
||||
.token_space {
|
||||
/* images/white_space.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
.token_tab {
|
||||
/* images/white_tab.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
.line_caret,
|
||||
.annotationLine.currentLine { /* Current line */
|
||||
background: hsl(208, 93%, 94%);
|
||||
}
|
||||
|
||||
.readonly .line_caret,
|
||||
.readonly .annotationLine.currentLine {
|
||||
background: hsl(208, 80%, 90%);
|
||||
}
|
||||
|
||||
/* Styling for html syntax highlighting */
|
||||
.entity-name-tag {
|
||||
color: hsl(208,48%,40%); /* blue */
|
||||
}
|
||||
|
||||
.entity-other-attribute-name {
|
||||
color: hsl(208,48%,40%); /* blue */
|
||||
}
|
||||
|
||||
.punctuation-definition-comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.string-quoted {
|
||||
color: hsl(24,85%,39%); /* orange */
|
||||
}
|
||||
|
||||
.invalid {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
|
@ -262,12 +262,9 @@ browser.jar:
|
|||
skin/classic/browser/devtools/ruleview.css (devtools/ruleview.css)
|
||||
skin/classic/browser/devtools/commandline.css (devtools/commandline.css)
|
||||
skin/classic/browser/devtools/markup-view.css (../shared/devtools/markup-view.css)
|
||||
skin/classic/browser/devtools/orion.css (devtools/orion.css)
|
||||
skin/classic/browser/devtools/orion-container.css (devtools/orion-container.css)
|
||||
skin/classic/browser/devtools/orion-task.png (devtools/orion-task.png)
|
||||
skin/classic/browser/devtools/orion-error.png (devtools/orion-error.png)
|
||||
skin/classic/browser/devtools/orion-breakpoint.png (devtools/orion-breakpoint.png)
|
||||
skin/classic/browser/devtools/orion-debug-location.png (devtools/orion-debug-location.png)
|
||||
skin/classic/browser/devtools/editor-error.png (devtools/editor-error.png)
|
||||
skin/classic/browser/devtools/editor-breakpoint.png (devtools/editor-breakpoint.png)
|
||||
skin/classic/browser/devtools/editor-debug-location.png (devtools/editor-debug-location.png)
|
||||
* skin/classic/browser/devtools/webconsole.css (devtools/webconsole.css)
|
||||
skin/classic/browser/devtools/webconsole_networkpanel.css (devtools/webconsole_networkpanel.css)
|
||||
skin/classic/browser/devtools/webconsole.png (devtools/webconsole.png)
|
||||
|
|
Двоичные данные
browser/themes/windows/devtools/orion-breakpoint.png
До Ширина: | Высота: | Размер: 577 B |
|
@ -1,39 +0,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/. */
|
||||
|
||||
.viewTooltip {
|
||||
display: none; /* TODO: add tooltips support, see bug 721752 */
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
background-color: InfoBackground;
|
||||
color: InfoText;
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid black;
|
||||
z-index: 100;
|
||||
position: fixed;
|
||||
overflow: hidden;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.viewTooltip em {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotationHTML.task {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
.annotationHTML.breakpoint {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
Двоичные данные
browser/themes/windows/devtools/orion-debug-location.png
До Ширина: | Высота: | Размер: 308 B |
Двоичные данные
browser/themes/windows/devtools/orion-error.png
До Ширина: | Высота: | Размер: 3.7 KiB |
Двоичные данные
browser/themes/windows/devtools/orion-task.png
До Ширина: | Высота: | Размер: 413 B |
|
@ -1,199 +0,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/. */
|
||||
|
||||
.viewContainer {
|
||||
background: hsl(0,0%,89%); /* This will be seen as the continuation of the ruler */
|
||||
font-family: monospace;
|
||||
font-size: inherit; /* inherit browser's default monospace font size */
|
||||
}
|
||||
|
||||
.view {
|
||||
color: black; /* Default text color */
|
||||
background: white; /* Background of the editor */
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.readonly > .view {
|
||||
background: #fdfefd; /* super light green */
|
||||
}
|
||||
|
||||
.ruler {
|
||||
background: hsl(0,0%,89%);
|
||||
color: hsl(0,0%,55%);
|
||||
}
|
||||
.ruler.annotations {
|
||||
width: 16px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
.ruler.lines {
|
||||
border-right: 1px solid #b4c4d3;
|
||||
min-width: 1.4em;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.ruler.linesWithAnnotations {
|
||||
min-width: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.ruler.overview {
|
||||
border-left: 1px solid #b4c4d3;
|
||||
width: 14px;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
/* Styles for the annotation ruler (first line) */
|
||||
.annotationHTML {
|
||||
cursor: pointer;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.annotation.task .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
.annotation.breakpoint .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
||||
.annotation.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
|
||||
}
|
||||
.annotation.breakpoint.debugLocation .annotationHTML,
|
||||
.annotation.task.debugLocation .annotationHTML {
|
||||
background-position: center, center;
|
||||
background-repeat: no-repeat, no-repeat;
|
||||
background-size: 75%, 100%;
|
||||
}
|
||||
.annotation.breakpoint.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-breakpoint.png");
|
||||
}
|
||||
|
||||
.annotation.task.debugLocation .annotationHTML {
|
||||
background-image: url("chrome://browser/skin/devtools/orion-debug-location.png"),
|
||||
url("chrome://browser/skin/devtools/orion-task.png");
|
||||
}
|
||||
|
||||
/* Styles for the overview ruler */
|
||||
.annotationOverview {
|
||||
cursor: pointer;
|
||||
border-radius: 2px;
|
||||
left: 2px;
|
||||
width: 8px;
|
||||
}
|
||||
.annotationOverview.task {
|
||||
background-color: lightgreen;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.breakpoint {
|
||||
background-color: lightblue;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
.annotationOverview.debugLocation {
|
||||
background-color: white;
|
||||
border: 1px solid green;
|
||||
}
|
||||
.annotationOverview.currentBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
.annotationOverview.matchingBracket {
|
||||
background-color: lightgray;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
/* Styles for text range */
|
||||
.annotationRange {
|
||||
background-repeat: repeat-x;
|
||||
background-position: left bottom;
|
||||
}
|
||||
.annotationRange.task {
|
||||
outline: 1px dashed rgba(0, 255, 0, 0.5);
|
||||
}
|
||||
.annotationRange.matchingBracket {
|
||||
outline: 1px solid grey;
|
||||
}
|
||||
|
||||
.token_singleline_comment,
|
||||
.token_multiline_comment,
|
||||
.token_doc_comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.token_doc_html_markup {
|
||||
color: #dd0058; /* purple */
|
||||
}
|
||||
|
||||
.token_doc_tag {
|
||||
color: #dd0058; /* purple */
|
||||
}
|
||||
|
||||
.token_task_tag { /* "TODO" */
|
||||
color: black;
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.token_string {
|
||||
color: hsl(72,100%,27%); /* green */
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token_keyword {
|
||||
color: hsl(276,44%,45%); /* purple */
|
||||
}
|
||||
|
||||
.token_space {
|
||||
/* images/white_space.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
.token_tab {
|
||||
/* images/white_tab.png */
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
.line_caret,
|
||||
.annotationLine.currentLine { /* Current line */
|
||||
background: hsl(208, 93%, 94%);
|
||||
}
|
||||
|
||||
.readonly .line_caret,
|
||||
.readonly .annotationLine.currentLine {
|
||||
background: hsl(208, 80%, 90%);
|
||||
}
|
||||
|
||||
/* Styling for html syntax highlighting */
|
||||
.entity-name-tag {
|
||||
color: hsl(208,48%,40%); /* blue */
|
||||
}
|
||||
|
||||
.entity-other-attribute-name {
|
||||
color: hsl(208,48%,40%); /* blue */
|
||||
}
|
||||
|
||||
.punctuation-definition-comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.comment {
|
||||
color: hsl(90,2%,50%); /* grey */
|
||||
}
|
||||
|
||||
.string-quoted {
|
||||
color: hsl(24,85%,39%); /* orange */
|
||||
}
|
||||
|
||||
.invalid {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
|
@ -184,12 +184,9 @@ browser.jar:
|
|||
skin/classic/browser/devtools/command-scratchpad.png (devtools/command-scratchpad.png)
|
||||
skin/classic/browser/devtools/command-tilt.png (devtools/command-tilt.png)
|
||||
skin/classic/browser/devtools/markup-view.css (../shared/devtools/markup-view.css)
|
||||
skin/classic/browser/devtools/orion.css (devtools/orion.css)
|
||||
skin/classic/browser/devtools/orion-container.css (devtools/orion-container.css)
|
||||
skin/classic/browser/devtools/orion-task.png (devtools/orion-task.png)
|
||||
skin/classic/browser/devtools/orion-error.png (devtools/orion-error.png)
|
||||
skin/classic/browser/devtools/orion-breakpoint.png (devtools/orion-breakpoint.png)
|
||||
skin/classic/browser/devtools/orion-debug-location.png (devtools/orion-debug-location.png)
|
||||
skin/classic/browser/devtools/editor-error.png (devtools/editor-error.png)
|
||||
skin/classic/browser/devtools/editor-breakpoint.png (devtools/editor-breakpoint.png)
|
||||
skin/classic/browser/devtools/editor-debug-location.png (devtools/editor-debug-location.png)
|
||||
* skin/classic/browser/devtools/webconsole.css (devtools/webconsole.css)
|
||||
skin/classic/browser/devtools/webconsole_networkpanel.css (devtools/webconsole_networkpanel.css)
|
||||
skin/classic/browser/devtools/webconsole.png (devtools/webconsole.png)
|
||||
|
@ -480,12 +477,9 @@ browser.jar:
|
|||
skin/classic/aero/browser/devtools/ruleview.css (devtools/ruleview.css)
|
||||
skin/classic/aero/browser/devtools/commandline.css (devtools/commandline.css)
|
||||
skin/classic/aero/browser/devtools/markup-view.css (../shared/devtools/markup-view.css)
|
||||
skin/classic/aero/browser/devtools/orion.css (devtools/orion.css)
|
||||
skin/classic/aero/browser/devtools/orion-container.css (devtools/orion-container.css)
|
||||
skin/classic/aero/browser/devtools/orion-task.png (devtools/orion-task.png)
|
||||
skin/classic/aero/browser/devtools/orion-error.png (devtools/orion-error.png)
|
||||
skin/classic/aero/browser/devtools/orion-breakpoint.png (devtools/orion-breakpoint.png)
|
||||
skin/classic/aero/browser/devtools/orion-debug-location.png (devtools/orion-debug-location.png)
|
||||
skin/classic/aero/browser/devtools/editor-error.png (devtools/editor-error.png)
|
||||
skin/classic/aero/browser/devtools/editor-breakpoint.png (devtools/editor-breakpoint.png)
|
||||
skin/classic/aero/browser/devtools/editor-debug-location.png (devtools/editor-debug-location.png)
|
||||
* skin/classic/aero/browser/devtools/webconsole.css (devtools/webconsole.css)
|
||||
skin/classic/aero/browser/devtools/webconsole_networkpanel.css (devtools/webconsole_networkpanel.css)
|
||||
skin/classic/aero/browser/devtools/webconsole.png (devtools/webconsole.png)
|
||||
|
|