mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-26 04:22:30 -10:00
The -*- file variable lines -*- establish per-file settings that Emacs will pick up. This patch makes the following changes to those lines (and touches nothing else): - Never set the buffer's mode. Years ago, Emacs did not have a good JavaScript mode, so it made sense to use Java or C++ mode in .js files. However, Emacs has had js-mode for years now; it's perfectly serviceable, and is available and enabled by default in all major Emacs packagings. Selecting a mode in the -*- file variable line -*- is almost always the wrong thing to do anyway. It overrides Emacs's default choice, which is (now) reasonable; and even worse, it overrides settings the user might have made in their '.emacs' file for that file extension. It's only useful when there's something specific about that particular file that makes a particular mode appropriate. - Correctly propagate settings that establish the correct indentation level for this file: c-basic-offset and js2-basic-offset should be js-indent-level. Whatever value they're given should be preserved; different parts of our tree use different indentation styles. - We don't use tabs in Mozilla JS code. Always set indent-tabs-mode: nil. Remove tab-width: settings, at least in files that don't contain tab characters. - Remove js2-mode settings that belong in the user's .emacs file, like js2-skip-preprocessor-directives.
107 lines
2.7 KiB
JavaScript
107 lines
2.7 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
const { LongStringActor } = devtools.require("devtools/server/actors/script");
|
|
|
|
function run_test()
|
|
{
|
|
Cu.import("resource://gre/modules/jsdebugger.jsm");
|
|
addDebuggerToGlobal(this);
|
|
|
|
test_LSA_disconnect();
|
|
test_LSA_grip();
|
|
test_LSA_onSubstring();
|
|
}
|
|
|
|
const TEST_STRING = "This is a very long string!";
|
|
|
|
function makeMockLongStringActor()
|
|
{
|
|
let string = TEST_STRING;
|
|
let actor = new LongStringActor(string);
|
|
actor.actorID = "longString1";
|
|
actor.registeredPool = {
|
|
longStringActors: {
|
|
longString1: actor
|
|
}
|
|
};
|
|
return actor;
|
|
}
|
|
|
|
function test_LSA_disconnect()
|
|
{
|
|
let actor = makeMockLongStringActor();
|
|
do_check_eq(actor.registeredPool.longStringActors[actor.actorID], actor);
|
|
|
|
actor.disconnect();
|
|
do_check_eq(actor.registeredPool.longStringActors[actor.actorID], void 0);
|
|
}
|
|
|
|
function test_LSA_substring()
|
|
{
|
|
let actor = makeMockLongStringActor();
|
|
do_check_eq(actor._substring(0, 4), TEST_STRING.substring(0, 4));
|
|
do_check_eq(actor._substring(6, 9), TEST_STRING.substring(6, 9));
|
|
do_check_eq(actor._substring(0, TEST_STRING.length), TEST_STRING);
|
|
}
|
|
|
|
function test_LSA_grip()
|
|
{
|
|
let actor = makeMockLongStringActor();
|
|
|
|
let grip = actor.grip();
|
|
do_check_eq(grip.type, "longString");
|
|
do_check_eq(grip.initial, TEST_STRING.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
|
|
do_check_eq(grip.length, TEST_STRING.length);
|
|
do_check_eq(grip.actor, actor.actorID);
|
|
}
|
|
|
|
function test_LSA_onSubstring()
|
|
{
|
|
let actor = makeMockLongStringActor();
|
|
let response;
|
|
|
|
// From the start
|
|
response = actor.onSubstring({
|
|
start: 0,
|
|
end: 4
|
|
});
|
|
do_check_eq(response.from, actor.actorID);
|
|
do_check_eq(response.substring, TEST_STRING.substring(0, 4));
|
|
|
|
// In the middle
|
|
response = actor.onSubstring({
|
|
start: 5,
|
|
end: 8
|
|
});
|
|
do_check_eq(response.from, actor.actorID);
|
|
do_check_eq(response.substring, TEST_STRING.substring(5, 8));
|
|
|
|
// Whole string
|
|
response = actor.onSubstring({
|
|
start: 0,
|
|
end: TEST_STRING.length
|
|
});
|
|
do_check_eq(response.from, actor.actorID);
|
|
do_check_eq(response.substring, TEST_STRING);
|
|
|
|
// Negative index
|
|
response = actor.onSubstring({
|
|
start: -5,
|
|
end: TEST_STRING.length
|
|
});
|
|
do_check_eq(response.from, actor.actorID);
|
|
do_check_eq(response.substring,
|
|
TEST_STRING.substring(-5, TEST_STRING.length));
|
|
|
|
// Past the end
|
|
response = actor.onSubstring({
|
|
start: TEST_STRING.length - 5,
|
|
end: 100
|
|
});
|
|
do_check_eq(response.from, actor.actorID);
|
|
do_check_eq(response.substring,
|
|
TEST_STRING.substring(TEST_STRING.length - 5, 100));
|
|
}
|