michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: var gDebuggee; michael@0: var gClient; michael@0: var gThreadClient; michael@0: michael@0: function run_test() michael@0: { michael@0: initTestDebuggerServer(); michael@0: gDebuggee = addTestGlobal("test-grips"); michael@0: gDebuggee.eval(function stopMe(arg1) { michael@0: debugger; michael@0: }.toString()); michael@0: michael@0: gClient = new DebuggerClient(DebuggerServer.connectPipe()); michael@0: gClient.connect(function() { michael@0: attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { michael@0: gThreadClient = aThreadClient; michael@0: test_longstring_grip(); michael@0: }); michael@0: }); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function test_longstring_grip() michael@0: { michael@0: let longString = "All I want is to be a monkey of moderate intelligence who" michael@0: + " wears a suit... that's why I'm transferring to business school! Maybe I" michael@0: + " love you so much, I love you no matter who you are pretending to be." michael@0: + " Enough about your promiscuous mother, Hermes! We have bigger problems." michael@0: + " For example, if you killed your grandfather, you'd cease to exist! What" michael@0: + " kind of a father would I be if I said no? Yep, I remember. They came in" michael@0: + " last at the Olympics, then retired to promote alcoholic beverages! And" michael@0: + " remember, don't do anything that affects anything, unless it turns out" michael@0: + " you were supposed to, in which case, for the love of God, don't not do" michael@0: + " it!"; michael@0: michael@0: DebuggerServer.LONG_STRING_LENGTH = 200; michael@0: michael@0: gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { michael@0: let args = aPacket.frame.arguments; michael@0: do_check_eq(args.length, 1); michael@0: let grip = args[0]; michael@0: michael@0: try { michael@0: do_check_eq(grip.type, "longString"); michael@0: do_check_eq(grip.length, longString.length); michael@0: do_check_eq(grip.initial, longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH)); michael@0: michael@0: let longStringClient = gThreadClient.pauseLongString(grip); michael@0: longStringClient.substring(22, 28, function (aResponse) { michael@0: try { michael@0: do_check_eq(aResponse.substring, "monkey"); michael@0: } finally { michael@0: gThreadClient.resume(function() { michael@0: finishClient(gClient); michael@0: }); michael@0: } michael@0: }); michael@0: } catch(error) { michael@0: gThreadClient.resume(function() { michael@0: finishClient(gClient); michael@0: do_throw(error); michael@0: }); michael@0: } michael@0: }); michael@0: michael@0: gDebuggee.eval('stopMe("' + longString + '")'); michael@0: } michael@0: