1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_longstringgrips-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +var gDebuggee; 1.8 +var gClient; 1.9 +var gThreadClient; 1.10 + 1.11 +function run_test() 1.12 +{ 1.13 + initTestDebuggerServer(); 1.14 + gDebuggee = addTestGlobal("test-grips"); 1.15 + gDebuggee.eval(function stopMe(arg1) { 1.16 + debugger; 1.17 + }.toString()); 1.18 + 1.19 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.20 + gClient.connect(function() { 1.21 + attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { 1.22 + gThreadClient = aThreadClient; 1.23 + test_longstring_grip(); 1.24 + }); 1.25 + }); 1.26 + do_test_pending(); 1.27 +} 1.28 + 1.29 +function test_longstring_grip() 1.30 +{ 1.31 + let longString = "All I want is to be a monkey of moderate intelligence who" 1.32 + + " wears a suit... that's why I'm transferring to business school! Maybe I" 1.33 + + " love you so much, I love you no matter who you are pretending to be." 1.34 + + " Enough about your promiscuous mother, Hermes! We have bigger problems." 1.35 + + " For example, if you killed your grandfather, you'd cease to exist! What" 1.36 + + " kind of a father would I be if I said no? Yep, I remember. They came in" 1.37 + + " last at the Olympics, then retired to promote alcoholic beverages! And" 1.38 + + " remember, don't do anything that affects anything, unless it turns out" 1.39 + + " you were supposed to, in which case, for the love of God, don't not do" 1.40 + + " it!"; 1.41 + 1.42 + DebuggerServer.LONG_STRING_LENGTH = 200; 1.43 + 1.44 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.45 + let args = aPacket.frame.arguments; 1.46 + do_check_eq(args.length, 1); 1.47 + let grip = args[0]; 1.48 + 1.49 + try { 1.50 + do_check_eq(grip.type, "longString"); 1.51 + do_check_eq(grip.length, longString.length); 1.52 + do_check_eq(grip.initial, longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH)); 1.53 + 1.54 + let longStringClient = gThreadClient.pauseLongString(grip); 1.55 + longStringClient.substring(22, 28, function (aResponse) { 1.56 + try { 1.57 + do_check_eq(aResponse.substring, "monkey"); 1.58 + } finally { 1.59 + gThreadClient.resume(function() { 1.60 + finishClient(gClient); 1.61 + }); 1.62 + } 1.63 + }); 1.64 + } catch(error) { 1.65 + gThreadClient.resume(function() { 1.66 + finishClient(gClient); 1.67 + do_throw(error); 1.68 + }); 1.69 + } 1.70 + }); 1.71 + 1.72 + gDebuggee.eval('stopMe("' + longString + '")'); 1.73 +} 1.74 +