parent
c4fac4e852
commit
64890af9bf
|
@ -295,6 +295,14 @@
|
|||
<cocoa class="NSScriptCommand"/>
|
||||
<direct-parameter type="specifier" description="the object to reload"/>
|
||||
</command>
|
||||
<command name="runJS" code="104FxrJS" description="Runs JavaScript in the context of an object.">
|
||||
<cocoa class="NSScriptCommand"/>
|
||||
<direct-parameter type="specifier" description="the object context"/>
|
||||
<parameter name="script" code="scpt" type="text" description="The script source text.">
|
||||
<cocoa key="script"/>
|
||||
</parameter>
|
||||
<result type="text" description="String value returned by the script."/>
|
||||
</command>
|
||||
<class name="tab" code="BTab" description="A %MAC_APP_NAME% browser window tab." inherits="item" plural="tabs">
|
||||
<cocoa class="GeckoTab"/>
|
||||
<property name="name" code="pnam" type="text" access="r" description="The name of the tab.">
|
||||
|
@ -324,6 +332,9 @@
|
|||
<responds-to name="reload">
|
||||
<cocoa method="handleReloadScriptCommand:"/>
|
||||
</responds-to>
|
||||
<responds-to name="runJS">
|
||||
<cocoa method="handleRunJavaScriptCommand:"/>
|
||||
</responds-to>
|
||||
<!--
|
||||
<responds-to name="print">
|
||||
<cocoa method="handlePrintScriptCommand:"/>
|
||||
|
|
|
@ -981,6 +981,7 @@ BrowserGlue.prototype = {
|
|||
},
|
||||
runScriptInTabAtIndexInWindow : function(index, window_index,
|
||||
script) {
|
||||
Services.console.logStringMessage("Got script: "+script);
|
||||
throw Components.Exception("NYI", Cr.NS_ERROR_FAILURE);
|
||||
return null;
|
||||
}
|
||||
|
@ -1249,9 +1250,9 @@ BrowserGlue.prototype = {
|
|||
this._resetUnusedProfileNotification();
|
||||
}
|
||||
|
||||
this._checkForOldBuildUpdates();
|
||||
//this._checkForOldBuildUpdates();
|
||||
|
||||
this._firstWindowTelemetry(aWindow);
|
||||
//this._firstWindowTelemetry(aWindow);
|
||||
this._firstWindowLoaded();
|
||||
},
|
||||
|
||||
|
@ -1337,8 +1338,8 @@ BrowserGlue.prototype = {
|
|||
|
||||
// If there are plugins installed that are outdated, and the user hasn't
|
||||
// been warned about them yet, open the plugins update page.
|
||||
if (Services.prefs.getBoolPref(PREF_PLUGINS_NOTIFYUSER))
|
||||
this._showPluginUpdatePage();
|
||||
//if (Services.prefs.getBoolPref(PREF_PLUGINS_NOTIFYUSER))
|
||||
// this._showPluginUpdatePage();
|
||||
|
||||
// For any add-ons that were installed disabled and can be enabled offer
|
||||
// them to the user.
|
||||
|
|
|
@ -182,6 +182,7 @@ typedef unsigned int NSUInteger;
|
|||
|
||||
- (id)handleCloseScriptCommand:(NSCloseCommand*)command;
|
||||
- (id)handleReloadScriptCommand:(NSScriptCommand*)command;
|
||||
- (NSString*)handleRunJavaScriptCommand:(NSScriptCommand*)command;
|
||||
|
||||
// Helper Methods
|
||||
- (void)_setWindow:(GeckoWindow*)window;
|
||||
|
@ -757,7 +758,7 @@ static BOOL didInit = NO;
|
|||
geckoURL.Assign([newURL UTF8String]);
|
||||
if (NS_FAILED(NS_NewURI(&uri, geckoURL, nullptr, nullptr, nsContentUtils::GetIOService()))) {
|
||||
if (c) {
|
||||
[c setScriptErrorNumber:-1700]; // errAECoercionFail
|
||||
[c setScriptErrorNumber:-2131]; // urlDataHHTTPURLErr
|
||||
[c setScriptErrorString:@"Parameter Error: URL is not valid."];
|
||||
}
|
||||
return;
|
||||
|
@ -883,6 +884,32 @@ static BOOL didInit = NO;
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (NSString*)handleRunJavaScriptCommand:(NSScriptCommand*)command {
|
||||
nsCOMPtr<nsIApplescriptService> applescriptService(do_GetService("@mozilla.org/applescript-service;1"));
|
||||
if (applescriptService) {
|
||||
NSDictionary *args = [command evaluatedArguments];
|
||||
if (args) {
|
||||
NSString *script = [args objectForKey:@"script"];
|
||||
if (script) {
|
||||
nsAutoCString s, r;
|
||||
bool ok;
|
||||
|
||||
s.Assign([script UTF8String]);
|
||||
if (NS_SUCCEEDED(applescriptService->RunScriptInTabAtIndexInWindow(mIndex,
|
||||
[mWindow orderedIndex],
|
||||
s, r, &ok))) {
|
||||
if (ok)
|
||||
return [NSString stringWithUTF8String:r.get()];
|
||||
|
||||
[command setScriptErrorNumber:-2740]; // OSASyntaxError
|
||||
[command setScriptErrorString:@"Parameter Error: Failed to run JavaScript."]; // XXX
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
|
Loading…
Reference in New Issue