Applescript: unexpected system beep from "display alert/dialog" cancel buttons, toolbar only

RESOLVED FIXED in Camino1.6

Status

--
trivial
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: lthompson.22, Assigned: stuart.morgan+bugzilla)

Tracking

({fixed1.8.1.13})

unspecified
Camino1.6
PowerPC
Mac OS X
fixed1.8.1.13

Details

Attachments

(2 attachments)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.13pre) Gecko/20080304 Camino/1.6b3pre (like Firefox/2.0.0.13pre)
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.13pre) Gecko/20080304 Camino/1.6b3pre (like Firefox/2.0.0.13pre)

I get a system beep when I run a script *from the toolbar* and click on a "display alert" or "display dialog" button that has been designated as the cancel button. This is consistent and I get the expected behavior, too, along with the beep: the dialog is dismissed and the script is terminated. For example, clicking on "bar" will generate a beep (and cancel) in all of the following:

   display dialog "foo" buttons {"bar"} cancel button 1
   display alert "foo" buttons {"bar", "OK"} cancel button "bar"
   display alert "foo" buttons {"Cancel", "bar", "OK"} cancel button 2

I also get a beep when clicking on "Cancel" from a "display dialog" statement with the usual 2-button Cancel/OK set, even if the cancel button is not specified:

   display dialog "foo" buttons {"Cancel", "OK"}
	
If I substitute "display alert" in the above, I don't get a system beep (but I don't get cancellation either since alerts don't cancel without specifying a cancel button).

The same scripts run from the Camino script menu do not generate any beeps. 

I tested this with a clean profile and clean org.mozilla.camino prefs, only the one test script in the Camino script folder, no other apps running, different system sounds.

I'll upload a script that can be used to test -- it's just a series of six alert/dialogs that demonstrate what I'm seeing (or hearing). I use 10.5.2. I don't remember exactly, but I'm not sure that alerts and/or the ability to designate a cancel button were available in 10.3, so it might not run on that system.


Reproducible: Always

Steps to Reproduce:
1. Save an applescript with one of the above statements.
2. Place script on Camino toolbar.
3. Run script to get dialog/alert.
4. Click the dialog button that's been specified as "cancel button".
Actual Results:  
Along with expected results, a system beep is generated.

Expected Results:  
Dialog/alert is dismissed, script is terminated (no beep).
(Reporter)

Comment 1

11 years ago
Created attachment 307402 [details]
applescript to test/demonstrate unexpected system beep

might not work on 10.3
Component: Toolbars & Menus → OS Integration
QA Contact: toolbars → os.integration
(Assignee)

Comment 2

11 years ago
We deliberately beep when executing the script returns an error, and apparently
canceling counts as an error in AS. It looks like we should check that the
error dictionary isn't returning an NSAppleScriptErrorNumber of -128 (user
cancelled), since that's not really an error case.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Peter, is this something that's safe and simple enough to fix for 1.6 final?
(Assignee)

Comment 4

11 years ago
The fix is very simple; we should do it for 1.6.
Target Milestone: --- → Camino1.6
Ah, yes, I'd forgotten AS handles cancels as errors.  Stuart's right, the fix is simple, if we know what we want.  Is the consensus to just filter out -128?  That sounds reasonable.
Status: NEW → ASSIGNED
Assignee: nobody → peter.a.jaros
Status: ASSIGNED → NEW
(Assignee)

Comment 6

11 years ago
Yep. I skimmed a bunch of the error codes and didn't see anything else obvious that we should filter, so -128 looks like the only one we need to check for.
(Assignee)

Comment 7

11 years ago
Created attachment 311201 [details] [diff] [review]
fix

Stealing this, so the 1.6 list can be that much shorter ;)
Assignee: peter.a.jaros → stuart.morgan
Status: NEW → ASSIGNED
Attachment #311201 - Flags: superreview?(mikepinkerton)
Comment on attachment 311201 [details] [diff] [review]
fix

sr=pink
Attachment #311201 - Flags: superreview?(mikepinkerton) → superreview+
(Assignee)

Comment 9

11 years ago
Landed on trunk and MOZILLA_1_8_BRANCH.
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Keywords: fixed1.8.1.13
Resolution: --- → FIXED
Sorry for the delinquency.  Thanks Stuart! :)
You need to log in before you can comment on or make changes to this bug.