diff options
-rw-r--r-- | Resources/Plists/PreferenceDefaults.plist | 2 | ||||
-rw-r--r-- | Source/SPBundleHTMLOutputController.m | 46 |
2 files changed, 45 insertions, 3 deletions
diff --git a/Resources/Plists/PreferenceDefaults.plist b/Resources/Plists/PreferenceDefaults.plist index 71fca976..093174a2 100644 --- a/Resources/Plists/PreferenceDefaults.plist +++ b/Resources/Plists/PreferenceDefaults.plist @@ -173,5 +173,7 @@ <true/> <key>FilterTableDefaultOperator</key> <string>LIKE '%@%'</string> + <key>WebKitDeveloperExtras</key> + <true/> </dict> </plist> diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m index 8a5b66e6..7cad079b 100644 --- a/Source/SPBundleHTMLOutputController.m +++ b/Source/SPBundleHTMLOutputController.m @@ -25,6 +25,8 @@ #import "SPBundleHTMLOutputController.h" #import "SPAlertSheets.h" +@class WebScriptCallFrame; + @implementation SPBundleHTMLOutputController @synthesize docTitle; @@ -300,6 +302,20 @@ } } +- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame +{ + if(error) { + NSLog(@"%@", [error localizedDescription]); + } +} + +- (void)webView:(WebView *)webView didFailLoadWithError:(NSError*)error forFrame:(WebFrame *)frame +{ + if(error) { + NSLog(@"%@", [error localizedDescription]); + } +} + #pragma mark - #pragma mark JS support @@ -329,10 +345,11 @@ return NO; } -- (void)webView:(WebView *)sender windowScriptObjectAvailable: (WebScriptObject *)windowScriptObject +- (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject { [windowScriptObject setValue:self forKey:@"system"]; + [webView setScriptDebugDelegate:self]; } + (NSString *)webScriptNameForSelector:(SEL)aSelector @@ -372,10 +389,33 @@ return YES; } -- (void)windowScriptObjectAvailable:(WebScriptObject*)webScriptObject { - [webScriptObject setValue:self forKey:@"system"]; +- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source baseLineNumber:(NSUInteger)lineNumber fromURL:(NSURL *)url withError:(NSError *)error forWebFrame:(WebFrame *)webFrame +{ + NSString *mes = [NSString stringWithFormat:@"Failed to parse JavaScript source:\nline = %ld\nerror = %@ with\n%@\nfor source = \n%@", lineNumber, [error localizedDescription], [error userInfo], source]; + + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"JavaScript Parsing Error", @"javascript parsing error") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:mes]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; } +- (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame sourceId:(NSInteger)sid line:(NSInteger)lineno forWebFrame:(WebFrame *)webFrame +{ + NSString *mes = [NSString stringWithFormat:@"Exception:\nline = %ld\nfunction = %@\ncaller = %@\nexception = %@", lineno, [frame functionName], [frame caller], [frame userInfo], [frame exception]]; + + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"JavaScript Exception", @"javascript exception") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:mes]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; +} /** * JavaScript window.system.getShellEnvironmentForName('a_key') function to * return the value for key keyName |