Closed Bug 1155342 Opened 9 years ago Closed 9 years ago

Disallow flagging [NewObject] methods with [Pure] or [Constant] or the corresponding [DependsOn] values

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox40 --- affected
firefox41 --- fixed

People

(Reporter: bzbarsky, Assigned: jj, Mentored)

References

(Blocks 1 open bug)

Details

(Whiteboard: [good first bug][lang=python])

Attachments

(1 file, 4 obsolete files)

Clearly something that's [NewObject] is not idempotent, so we shouldn't allow marking it [Pure].

It _could_ be marked as [DependsOn=DeviceState, Affects=Nothing], though, if it's side-effect-free. But [DependsOn=Nothing] and [DependsOn=DOMState] would be obvious lies.

We should enforce this in IDLInterfaceMember.validate.
Mentor: bzbarsky
Whiteboard: [good first bug][lang=python]
Hi I would like to work on this bug could you help me out how to start off with this ?
Flags: needinfo?(bzbarsky)
Have you already compiled Firefox?  If not, start with that.  If you have, then you want to be looking in dom/bindings/parser/WebIDL.py in the "validate" method of the IDLInterfaceMember class.

There are existing checks there for the self.dependsOn value.  You'd want to add another one: that if self.getExtendedAttribute("NewObject") then self.dependsOn is not "Nothing" and is not "DOMState".

Also probably a good idea to assert that self.dependsOn is in DependsOnValues.

Let me know if that's not enough to go on?
Flags: needinfo?(bzbarsky)
if self.getExtendedAttribute("NewObject"):
   if self.dependsOn != "Nothing" and self.dependsOn != "DOMState":
      raise WebIDLError("self.dependsOn is in DependsOnValues", [self.location])

I got and error while building it.
You got the check backwards, no?  You're raising an error precisely in the case when you shouldn't.
Then what should I do precisely ?
You should raise an error if self.getExtendedAttribute("NewObject") and the dependsOn value is "Nothing" or "DOMState".
Attached patch p1v1.diff (obsolete) — Splinter Review
OK, so now that's the right conditions.  The assertion about the self.dependsOn value being in DependsOnValues is missing, and the error message text is wrong.  It should be more like "A [NewObject] method is not idempotent, so it has to depend on something other than DOM state."
Attached patch p1v2.diff (obsolete) — Splinter Review
Attachment #8613084 - Flags: review?(bzbarsky)
Should I now go for a try push ?
Comment on attachment 8613084 [details] [diff] [review]
p1v2.diff

r=me.  Try push is good, yes.  Can you do that yourself, or should I do it?  Doing a build-only push on all platforms is enough here.
Attachment #8613084 - Flags: review?(bzbarsky) → review+
Ya I could do it on my own but could you tell me what would be try message syntax
Any Updates ?
Did your try run pass?  If it did, you should add the "checkin-needed" keyword to this bug.
There are some problem with windows could you please check those things I have posted the the treehereder link
Looks like your push was on top of a changeset that doesn't actually build on Windows.  I recommend picking a known-working changeset to do a try push on top of....
Flags: needinfo?(jinank94)
Still there are some bug with android build could you help me with that :)
Flags: needinfo?(bzbarsky)
That looks like infrastructure issues that have nothing to do with your patch.  This should be good to check in, but you need an actual commit message and user information in that diff, right?
Assignee: nobody → jinank94
Flags: needinfo?(bzbarsky) → needinfo?(jinank94)
Attached patch p1v3.diff (obsolete) — Splinter Review
Attachment #8613062 - Attachment is obsolete: true
Attachment #8613084 - Attachment is obsolete: true
Flags: needinfo?(jinank94)
Still needs a commit message.  The commit message will typically look something like:

  Bug NNNNN.  The stuff I changed.  r=reviewer

so in this case

  Bug 1155342.  Disallow flagging a [NewObject] method with a [DependsOn] value that implies it might return the same value when called twice.  r=bzbarsky

or so.
Attached patch p1v3.diff (obsolete) — Splinter Review
Attachment #8620508 - Attachment is obsolete: true
But without the try syntax in the commit message, yes?  ;)
Attached patch p1v3.diffSplinter Review
Attachment #8620525 - Attachment is obsolete: true
Flags: needinfo?(bzbarsky)
Much better, yes.
Flags: needinfo?(bzbarsky)
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/7f6477aa2270
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Jinank Jain, thank you for fixing this!
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: