Bug 71416 - Improve shouldThrow from js-test-pre.js
Summary: Improve shouldThrow from js-test-pre.js
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-02 16:15 PDT by Erik Arvidsson
Modified: 2011-11-03 11:27 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Arvidsson 2011-11-02 16:15:22 PDT
Currently we do an == to compare the expected exception. It would be good if we could pass a constructor and do an instanceof check instead,

Currently:

shouldThrow('localStorage.key()', '"TypeError: Not enough arguments"')

It would be useful to allow this too

shouldThrow('localStorage.key()', 'TypeError')

which would do an instanceof check instead.

We could even go one step further and also allow checking the message of the exception:

shouldThrow('localStorage.key()', 'TypeError', '"Not enough arguments"')

The benefit is that this would work better on different browsers where the toString of the exception does not match what we do in WebKit.
Comment 1 Alexey Proskuryakov 2011-11-03 11:27:31 PDT
Great idea!