+2006-07-11 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Darin.
+
+ Bug 9598: [Drosera] add a JavaScript evaluator console
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=9598
+
+ * Drosera/DebuggerApplication.h:
+ * Drosera/DebuggerApplication.m:
+ (-[DebuggerApplication knownServers]):
+ * Drosera/DebuggerDocument.h:
+ * Drosera/DebuggerDocument.m:
+ (-[WebScriptObject evaluateScript:inCallFrame:]):
+ (-[WebScriptObject showConsole:]):
+ (-[WebScriptObject toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:]):
+ (-[WebScriptObject toolbarDefaultItemIdentifiers:]):
+ (-[WebScriptObject toolbarAllowedItemIdentifiers:]):
+ (-[WebScriptObject webView:createWebViewWithRequest:]):
+ (-[WebScriptObject webViewShow:]):
+ (-[WebScriptObject webViewAreToolbarsVisible:]):
+ (-[WebScriptObject webView:setToolbarsVisible:]):
+ (-[WebScriptObject webView:setResizable:]):
+ (-[WebScriptObject webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
+ (-[WebScriptObject scriptConfirmSheetDidEnd:returnCode:contextInfo:]):
+ (-[WebScriptObject webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:]):
+ (-[WebScriptObject webView:windowScriptObjectAvailable:]):
+ (-[WebScriptObject webView:didFinishLoadForFrame:]):
+ (-[WebScriptObject webView:didReceiveTitle:forFrame:]):
+ * Drosera/Drosera.xcodeproj/project.pbxproj:
+ * Drosera/Images/console.png: Added.
+ * Drosera/console.css: Added.
+ * Drosera/console.html: Added.
+ * Drosera/console.js: Added.
+
2006-07-11 Timothy Hatcher <timothy@apple.com>
Reviewed by a tired Geoff.
}
- (IBAction)showAttachPanel:(id)sender;
- (IBAction)attach:(id)sender;
+
+- (NSDictionary *)knownServers;
@end
[attachTable reloadData];
}
+- (NSDictionary *)knownServers
+{
+ return knownServerNames;
+}
+
#pragma mark -
#pragma mark Attach Panel Actions
- (IBAction)stepInto:(id)sender;
- (IBAction)stepOver:(id)sender;
- (IBAction)stepOut:(id)sender;
+- (IBAction)showConsole:(id)sender;
@end
#import "DebuggerDocument.h"
#import "DebuggerApplication.h"
+static NSString *DebuggerConsoleToolbarItem = @"DebuggerConsoleToolbarItem";
static NSString *DebuggerContinueToolbarItem = @"DebuggerContinueToolbarItem";
static NSString *DebuggerPauseToolbarItem = @"DebuggerPauseToolbarItem";
static NSString *DebuggerStepIntoToolbarItem = @"DebuggerStepIntoToolbarItem";
return [result autorelease];
}
+- (id)evaluateScript:(NSString *)script inCallFrame:(int)frame
+{
+ WebScriptCallFrame *cframe = currentFrame;
+ for (unsigned count = 0; count < frame; count++)
+ cframe = [cframe caller];
+ if (!cframe)
+ return nil;
+
+ id result = [cframe evaluateWebScript:script];
+ if ([result isKindOfClass:NSClassFromString(@"WebScriptObject")])
+ return [result callWebScriptMethod:@"toString" withArguments:nil];
+ return result;
+}
+
- (NSArray *)webScriptAttributeKeysForScriptObject:(WebScriptObject *)object
{
WebScriptObject *func = [object evaluateWebScript:@"(function () { var result = new Array(); for (var x in this) { result.push(x); } return result; })"];
[[webView windowScriptObject] callWebScriptMethod:@"stepOut" withArguments:nil];
}
+- (IBAction)showConsole:(id)sender
+{
+ [[webView windowScriptObject] callWebScriptMethod:@"showConsoleWindow" withArguments:nil];
+}
+
#pragma mark -
#pragma mark Window Controller Overrides
[item setTarget:self];
[item setAction:@selector(resume:)];
+ return [item autorelease];
+ } else if ([itemIdentifier isEqualToString:DebuggerConsoleToolbarItem]) {
+ NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
+
+ [item setLabel:@"Console"];
+ [item setPaletteLabel:@"Console"];
+
+ [item setToolTip:@"Console"];
+ [item setImage:[NSImage imageNamed:@"console"]];
+
+ [item setTarget:self];
+ [item setAction:@selector(showConsole:)];
+
return [item autorelease];
} else if ([itemIdentifier isEqualToString:DebuggerPauseToolbarItem]) {
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
{
return [NSArray arrayWithObjects:DebuggerContinueToolbarItem, DebuggerPauseToolbarItem,
NSToolbarSeparatorItemIdentifier, DebuggerStepIntoToolbarItem, DebuggerStepOutToolbarItem,
- DebuggerStepOverToolbarItem, nil];
+ DebuggerStepOverToolbarItem, NSToolbarFlexibleSpaceItemIdentifier, DebuggerConsoleToolbarItem, nil];
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
- return [NSArray arrayWithObjects:DebuggerContinueToolbarItem, DebuggerPauseToolbarItem,
+ return [NSArray arrayWithObjects:DebuggerConsoleToolbarItem, DebuggerContinueToolbarItem, DebuggerPauseToolbarItem,
DebuggerStepIntoToolbarItem, DebuggerStepOutToolbarItem, DebuggerStepOverToolbarItem, NSToolbarCustomizeToolbarItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
}
return YES;
}
+#pragma mark -
+#pragma mark WebView UI Delegate
+
+- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
+{
+ WebView *newWebView = [[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil];
+ [newWebView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+ [newWebView setUIDelegate:self];
+ [newWebView setPolicyDelegate:self];
+ [newWebView setFrameLoadDelegate:self];
+ if (request)
+ [[newWebView mainFrame] loadRequest:request];
+
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSZeroRect styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSUnifiedTitleAndToolbarWindowMask) backing:NSBackingStoreBuffered defer:NO screen:[[webView window] screen]];
+ [window setReleasedWhenClosed:YES];
+ [newWebView setFrame:[[window contentView] frame]];
+ [[window contentView] addSubview:newWebView];
+ [newWebView release];
+
+ return newWebView;
+}
+
+- (void)webViewShow:(WebView *)sender
+{
+ [[sender window] makeKeyAndOrderFront:sender];
+}
+
+- (BOOL)webViewAreToolbarsVisible:(WebView *)sender
+{
+ return [[[sender window] toolbar] isVisible];
+}
+
+- (void)webView:(WebView *)sender setToolbarsVisible:(BOOL)visible
+{
+ [[[sender window] toolbar] setVisible:visible];
+}
+
+- (void)webView:(WebView *)sender setResizable:(BOOL)resizable
+{
+ [[sender window] setShowsResizeIndicator:resizable];
+ [[[sender window] standardWindowButton:NSWindowZoomButton] setEnabled:resizable];
+}
+
+- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
+{
+ NSRange range = [message rangeOfString:@"\t"];
+ NSString *title = @"Alert";
+ if (range.location != NSNotFound) {
+ title = [message substringToIndex:range.location];
+ message = [message substringFromIndex:(range.location + range.length)];
+ }
+
+ NSBeginInformationalAlertSheet(title, nil, nil, nil, [sender window], nil, NULL, NULL, NULL, message);
+}
+
+- (void)scriptConfirmSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(int *)contextInfo
+{
+ *contextInfo = returnCode;
+}
+
+- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
+{
+ NSRange range = [message rangeOfString:@"\t"];
+ NSString *title = @"Alert";
+ if (range.location != NSNotFound) {
+ title = [message substringToIndex:range.location];
+ message = [message substringFromIndex:(range.location + range.length)];
+ }
+
+ int result = NSNotFound;
+ NSBeginInformationalAlertSheet(title, nil, @"Cancel", nil, [sender window], self, @selector(scriptConfirmSheetDidEnd:returnCode:contextInfo:), NULL, &result, message);
+
+ while (result == NSNotFound) {
+ NSEvent *nextEvent = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
+ [[NSApplication sharedApplication] sendEvent:nextEvent];
+ }
+
+ return result;
+}
+
#pragma mark -
#pragma mark WebView Frame Load Delegate
- (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject
{
// note: this is the Debuggers's own WebView, not the one being debugged
- [[sender windowScriptObject] setValue:self forKey:@"DebuggerDocument"];
+ if ([[sender window] isEqual:[self window]])
+ [[sender windowScriptObject] setValue:self forKey:@"DebuggerDocument"];
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
// note: this is the Debuggers's own WebView, not the one being debugged
- webViewLoaded = YES;
+ if ([[sender window] isEqual:[self window]])
+ webViewLoaded = YES;
+}
+
+- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
+{
+ // note: this is the Debuggers's own WebViews, not the one being debugged
+ if ([frame isEqual:[sender mainFrame]]) {
+ NSDictionary *info = [[(DebuggerApplication *)[[NSApplication sharedApplication] delegate] knownServers] objectForKey:currentServerName];
+ NSString *processName = [info objectForKey:WebScriptDebugServerProcessNameKey];
+ if (info && [processName length]) {
+ NSMutableString *newTitle = [[NSMutableString alloc] initWithString:processName];
+ [newTitle appendString:@" - "];
+ [newTitle appendString:title];
+ [[sender window] setTitle:newTitle];
+ [newTitle release];
+ } else
+ [[sender window] setTitle:title];
+ }
}
#pragma mark -
1C4FFE5E0A466F5D0000D05D /* programCounterBreakPoint.tif in Resources */ = {isa = PBXBuildFile; fileRef = 1C4FFE5C0A466F5D0000D05D /* programCounterBreakPoint.tif */; };
1C4FFE5F0A466F5D0000D05D /* programCounterBreakPointDisabled.tif in Resources */ = {isa = PBXBuildFile; fileRef = 1C4FFE5D0A466F5D0000D05D /* programCounterBreakPointDisabled.tif */; };
1C6F83FF0A58E97D004FCD89 /* stepOut.tif in Resources */ = {isa = PBXBuildFile; fileRef = 1C6F83FE0A58E97D004FCD89 /* stepOut.tif */; };
+ 1C6F84520A58EDFE004FCD89 /* console.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C6F84510A58EDFE004FCD89 /* console.png */; };
+ 1C6F84550A58EE06004FCD89 /* console.css in Resources */ = {isa = PBXBuildFile; fileRef = 1C6F84530A58EE06004FCD89 /* console.css */; };
+ 1C6F84560A58EE06004FCD89 /* console.html in Resources */ = {isa = PBXBuildFile; fileRef = 1C6F84540A58EE06004FCD89 /* console.html */; };
+ 1C6F86730A59A18B004FCD89 /* console.js in Resources */ = {isa = PBXBuildFile; fileRef = 1C6F861F0A599F65004FCD89 /* console.js */; };
1C74F0350A47BF8300FEC632 /* viewer.html in Resources */ = {isa = PBXBuildFile; fileRef = 1C74F0340A47BF8300FEC632 /* viewer.html */; };
1C74F04B0A47BFE800FEC632 /* viewer.css in Resources */ = {isa = PBXBuildFile; fileRef = 1C74F03A0A47BFD600FEC632 /* viewer.css */; };
1C74F1850A47DEE600FEC632 /* DebuggerApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C74F1840A47DEE600FEC632 /* DebuggerApplication.m */; };
1C4FFE5C0A466F5D0000D05D /* programCounterBreakPoint.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = programCounterBreakPoint.tif; sourceTree = "<group>"; };
1C4FFE5D0A466F5D0000D05D /* programCounterBreakPointDisabled.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = programCounterBreakPointDisabled.tif; sourceTree = "<group>"; };
1C6F83FE0A58E97D004FCD89 /* stepOut.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = stepOut.tif; sourceTree = "<group>"; };
+ 1C6F84510A58EDFE004FCD89 /* console.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = console.png; sourceTree = "<group>"; };
+ 1C6F84530A58EE06004FCD89 /* console.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = console.css; sourceTree = "<group>"; };
+ 1C6F84540A58EE06004FCD89 /* console.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = console.html; sourceTree = "<group>"; };
+ 1C6F861F0A599F65004FCD89 /* console.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = console.js; sourceTree = "<group>"; };
1C74F0340A47BF8300FEC632 /* viewer.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = viewer.html; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C74F03A0A47BFD600FEC632 /* viewer.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = viewer.css; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C74F1830A47DEE600FEC632 /* DebuggerApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerApplication.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1CC058B70A44A210006FE533 /* Images */ = {
isa = PBXGroup;
children = (
+ 1C6F84510A58EDFE004FCD89 /* console.png */,
1C4FF7530A44F6320000D05D /* gutter.png */,
1C4FF91F0A45F3520000D05D /* glossyHeader.png */,
1CD434B10A4B86F800A007AB /* glossyHeaderPressed.png */,
1C4FF7430A44F5260000D05D /* debugger.css */,
1C74F0340A47BF8300FEC632 /* viewer.html */,
1C74F03A0A47BFD600FEC632 /* viewer.css */,
+ 1C6F861F0A599F65004FCD89 /* console.js */,
+ 1C6F84540A58EE06004FCD89 /* console.html */,
+ 1C6F84530A58EE06004FCD89 /* console.css */,
);
name = Classes;
sourceTree = "<group>";
1C2632DA0A4AF0D200EA7CD8 /* background_stripe.png in Resources */,
1CD434B20A4B86F800A007AB /* glossyHeaderPressed.png in Resources */,
1C6F83FF0A58E97D004FCD89 /* stepOut.tif in Resources */,
+ 1C6F84520A58EDFE004FCD89 /* console.png in Resources */,
+ 1C6F84550A58EE06004FCD89 /* console.css in Resources */,
+ 1C6F84560A58EE06004FCD89 /* console.html in Resources */,
+ 1C6F86730A59A18B004FCD89 /* console.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = c99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
C05733C908A9546B00998B17 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_C_LANGUAGE_STANDARD = c99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
+ */
+
+img { padding: 0; margin: 0; }
+body { margin: 0; padding: 0; overflow: hidden; }
+
+#main {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ right: 0;
+}
+
+#top {
+ position: absolute;
+ top: 0;
+ bottom: 50px;
+ left: 0;
+ right: 0;
+}
+
+#history {
+ position: absolute;
+ top: 20px;
+ bottom: 10px;
+ left: 0;
+ right: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+}
+
+#divider {
+ cursor: row-resize;
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ background: url(splitterDimple.tif) 50% no-repeat, url(splitterBar.tif) repeat-x;
+ height: 10px;
+}
+
+#input {
+ position: absolute;
+ box-sizing: border-box;
+ height: 50px;
+ max-height: 150px;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ -webkit-user-modify: read-write;
+ -webkit-nbsp-mode: space;
+ -webkit-line-break: after-white-space;
+ word-wrap: break-word;
+ outline: none;
+ font-family: monospace;
+ font-size: 11px;
+ line-height: 14px;
+ padding: 3px;
+}
+
+#history .row {
+ height: 38px;
+ padding: 4px;
+ box-sizing: border-box;
+ font-family: monospace;
+ font-size: 12px;
+}
+
+#history .row.alt {
+ background-color: rgb(237, 243, 254);
+}
+
+.expression {
+ color: blue;
+}
+
+.result {
+ color: navy;
+}
--- /dev/null
+<!--
+Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. 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.
+3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>Console</title>
+ <script type="text/javascript" src="console.js"></script>
+ <style type="text/css">
+ @import "console.css";
+ </style>
+</head>
+<body onload="loaded()">
+<div id="main">
+<div id="top">
+<div id="history"></div>
+<div id="divider"></div>
+</div>
+<div id="input"></div>
+</div>
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
+ */
+
+var inputElement = null;
+var mainWindow = window.opener;
+
+function loaded()
+{
+ inputElement = document.getElementById("input");
+ inputElement.addEventListener("keydown", inputKeyDown, false);
+ inputElement.focus();
+}
+
+function inputKeyDown(event)
+{
+ if (event.keyCode == 13 && !event.altKey) {
+ if (mainWindow.isPaused() && mainWindow.currentStack) {
+ sendScript(inputElement.innerText);
+ inputElement.innerText = "";
+ inputElement.focus();
+ } else
+ alert("The debugger needs to be paused.\tIn order to evaluate your script input you need to pause the debugger in the context of another script.");
+ event.preventDefault();
+ }
+}
+
+function sendScript(script)
+{
+ var history = document.getElementById("history");
+ var row = document.createElement("div");
+ row.className = "row";
+ if (history.childNodes.length % 2)
+ row.className += " alt";
+
+ var expression = document.createElement("div");
+ expression.className = "expression";
+ expression.innerText = script;
+ row.appendChild(expression);
+
+ var result = document.createElement("div");
+ result.className = "result";
+ result.innerText = mainWindow.DebuggerDocument.evaluateScript_inCallFrame_(script, mainWindow.currentCallFrame.index);
+ row.appendChild(result);
+
+ history.appendChild(row);
+ history.scrollTop = history.scrollHeight;
+
+ if (script.indexOf("="))
+ mainWindow.currentCallFrame.loadVariables();
+}