Closed Bug 308283 Opened 19 years ago Closed 17 years ago

stateFlags is a bit field and console.views.source2.progressListener.onStateChange should use & instead of == to check for something like STOP

Categories

(Other Applications Graveyard :: Venkman JS Debugger, enhancement)

x86
Windows XP
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: timeless, Assigned: Gijs)

References

()

Details

Attachments

(1 file, 2 obsolete files)

the code currently compares explicitly == against 0xc0010 (state_is_window | 
state_is_network | state_stop), i think it should probably be using & instead 
of ==.
Attached patch use & (obsolete) β€” β€” Splinter Review
Attachment #196061 - Flags: review?(silver)
Comment on attachment 196061 [details] [diff] [review]
use &

r=silver

(not sure I can review Venkman, but it looks good!)

It might be nice to actually use the hex version of the number to make it
clearer, though.
Attachment #196061 - Flags: review?(silver) → review+
Timeless, could you check this in?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 196061 [details] [diff] [review]
use &

>-    else if (stateFlags == 786448)
>+    else if (stateFlags & 786448)

Um, can we not use a magic number and use the actual constants on nsIWebProgressListener?

That number looks like (STATE_STOP | STATE_IS_NETWORK | STATE_IS_WINDOW)
Attachment #196061 - Flags: review-
QA Contact: caillon → venkman
Assignee: rginda → timeless
Attached patch Patch (obsolete) β€” β€” Splinter Review
Like this?
Assignee: timeless → gijskruitbosch+bugs
Attachment #196061 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #296138 - Flags: review?(caillon)
Comment on attachment 296138 [details] [diff] [review]
Patch

>+    const WINDOW = nsIWebProgressListener.STATE_IS_WINDOW;
>+    const NETWORK = nsIWebProgressListener.STATE_IS_NETWORK;

Nit, can you reverse these so they remain in the order they appear in the idl file?


>-    else if (stateFlags == 786448)
>+    else if (stateFlags & (STOP | WINDOW | NETWORK))


I don't think this does what you expect when stateFlags has one or two of the bits set, but not all three.  You probably want to add a bitmask variable, and make sure that the result of the bitwise AND operation is equal to the mask.  Sort of like http://mxr.mozilla.org/mozilla/source/xpfe/appshell/src/nsAppShellService.cpp#313
Attachment #296138 - Flags: review?(caillon) → review-
Attached patch Better Patch β€” β€” Splinter Review
Like this? :-)
Attachment #296138 - Attachment is obsolete: true
Attachment #302333 - Flags: review?(caillon)
Attachment #302333 - Flags: review?(caillon) → review+
Checking in mozilla/extensions/venkman/resources/content/venkman-views.js;
/cvsroot/mozilla/extensions/venkman/resources/content/venkman-views.js,v  <--  venkman-views.js
new revision: 1.42; previous revision: 1.41
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: