Closed Bug 128420 Opened 23 years ago Closed 23 years ago

[FIX]getComputedStyle should raise NOT_SUPPORTED_ERR

Categories

(Core :: DOM: CSS Object Model, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.2alpha

People

(Reporter: netdragon, Assigned: caillon)

Details

Attachments

(3 files)

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: file:///F:/netscape/projects/patchandtest/Bug/kitchensinkerror.html :: <TOP_LEVEL> :: line 65" data: no]
The error appeared in the javascript console.
Well, that's because you pass an undefined value for the element value of getComputedStyle(). Try adding an |alert (typeof elt);| right after you assign it. When you call document.getElementById("sink") there is no element with that ID. It doesn't get defined until after you run your JS. Define your element before trying to access it and you'll see that it does indeed work fine. Note though that the value will be practically useless to you though as it will be "auto". the top property only applies to positioned elements and thus returns the default value per the spec.
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Component: JavaScript Engine → DOM Style
Resolution: --- → INVALID
Attached file New
You're right.
I still don't like the exception it returned. It should give something a little more informative (object not initialized) or something.
Um... there is no object to not be initialized. There is a reference to an element and the reference is "null". It's a null pointer. That said, getComputedStyle is defined as returning no exceptions (even for stupid cases like this). I hate the DOM Style spec. So we should just be silently failing, with an assert in debug builds.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
to caillon, but feel free to punt to me if you don't want to deal. :)
Assignee: rogerl → caillon
Status: UNCONFIRMED → NEW
Ever confirmed: true
Setting default QA -
QA Contact: pschwartau → ian
Status: NEW → ASSIGNED
Summary: Error on GetComputedStyle → getComputedStyle should not raise exceptions
Target Milestone: --- → Future
Daniel, should this be fixed? Or will the new CSS OM allow this (or another?) exception? Let me know and I'll whip out a patch.
resolution is "should throw NOT_SUPPORTED_ERR DOMException"
Thanks Daniel. I'll have a patch tomorrow, about to go to bed.
Priority: -- → P3
Target Milestone: Future → mozilla1.2alpha
Daniel, could you r=? Boris, sr=?
Summary: getComputedStyle should not raise exceptions → [FIX]getComputedStyle should raise NOT_SUPPORTED_ERR
Comment on attachment 97210 [details] [diff] [review] Raise the right exception. sr=bzbarsky
Attachment #97210 - Flags: superreview+
Comment on attachment 97210 [details] [diff] [review] Raise the right exception. r=glazman check that in ! let's make the specs on thursday and be compliant on saturday :-)
Attachment #97210 - Flags: review+
So let it be written. So let it be done.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: