Files
palemoon27/toolkit/devtools/server/tests/unit/test_longstringactor.js
T
roytam1 a101af758e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 967319 - Sort object properties in natural order in the Variables View. r=jaws (e604fc318)
- Bug 1023386 - Split and filter properties remotely for objects. r=past (b4889035f)
- Bug 1149115 - Make sure source actors are created before breakpoints are reset;r=jlong (76561a3fd)
- Bug 1154606 - improve error in debugger when loading source fails r=jsantell (3678eca90)
- Bug 1159731 - Move all Addon actor subclasses to a dedicated file. r=ejpbruel (45e012a98)
- Bug 1096294 - Display pseudo-arrays like arrays in the console; r=pbrosset (b4b129b3a)
- Bug 1169064 - Part 1: Move ObjectActor to object.js r=fitzgen (579cb4f86)
- Bug 1169064 - Part 2: Formatted object.js and removed unused protocol request arguments r=fitzgen (4f3178a6a)
- Bug 792063 - Add status console shortcut to return the previous command result;r=past (fc1317f9b)
- Bug 1169064 - Part 3: Refactor LongStringActor, createValueGrip, stringIsLong and longStripGrip from script.js to object.js r=fitzgen (ecdff41b7)
- AltiVec/VMX is 32bit only, use double cast passing uintptr_t to int to fix compilation on PPC64 (93985b589)
- Bug 1084525 - Part 7: Expose Promise life time in object grip r=fitzgen (db5000041)
- Bug 1084525 - Part 8: Expose Promise time to settle in object grip r=fitzgen (65b7beb26)
- Bug 1084525 - Part 9: Implement getDependentPromises method in ObjectClient r=fitzgen (8cc8be31d)
- Bug 1148753 - Update browser content toolbox to create a TabSources instance. r=jryans (df6bf505f)
- Bug 1050691 - Click on a function on the console should go to the debugger. r=jlongster (e0d225db1)
- Bug 1084525 - Part 10: Implement getAllocationStack method in ObjectClient r=fitzgen (199ce4dd9)
- Bug 1084525 - Part 12: Fix eslint complaints in promise.js r=fitzgen (7d0a38afe)
- Bug 1084525 - Part 13: Add test for asserting the Promise allocation stack in chrome debugging r=fitzgen (60278cf1d)
- Bug 1164564 - Refactor Promise-backend.js so it can be required as a CommonJS module on the main thread;r=paolo (7cfe3cdd9)
- Bug 1181506 - Define Cc and Ci. r=Yoric (bc3968be3)
2021-04-20 09:17:23 +08:00

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/object");
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: {
[string]: actor
}
};
return actor;
}
function test_LSA_disconnect()
{
let actor = makeMockLongStringActor();
do_check_eq(actor.registeredPool.longStringActors[TEST_STRING], actor);
actor.disconnect();
do_check_eq(actor.registeredPool.longStringActors[TEST_STRING], 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));
}