Closed Bug 1023520 Opened 5 years ago Closed 5 years ago

WebIDL Globals cannot have method returning a Promise

Categories

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

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(1 file)

For fetch spec (http://fetch.spec.whatwg.org/#fetch-method), fetch() method is on WorkerGlobalScope. The globals Dedicated & SharedWorkerGlobalScope inherit from it.

WebIDL codegen traceback:
 0:16.01 Traceback (most recent call last):
 0:16.01   File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
 0:16.01     "__main__", fname, loader, pkg_name)
 0:16.01   File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
 0:16.01     exec code in run_globals
 0:16.01   File "/home/nikhil/mozilla-central-fetch/python/mozbuild/mozbuild/action/webidl.py", line 17, in <module>
 0:16.01     sys.exit(main(sys.argv[1:]))
 0:16.01   File "/home/nikhil/mozilla-central-fetch/python/mozbuild/mozbuild/action/webidl.py", line 13, in main
 0:16.01     manager.generate_build_files()
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/mozwebidlcodegen/__init__.py", line 263, in generate_build_files
 0:16.01     written, deps = self._generate_build_files_for_webidl(filename)
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/mozwebidlcodegen/__init__.py", line 464, in _generate_build_files_for_webidl
 0:16.01     root = CGBindingRoot(self._config, binding_stem, filename)
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 11341, in __init__
 0:16.01     cgthings.extend([CGDescriptor(x) for x in descriptors])
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 10277, in __init__
 0:16.01     cgThings.append(CGGeneric(define=str(properties)))
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 2309, in __str__
 0:16.01     define += str(getattr(self, array))
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 1858, in __str__
 0:16.01     self.usedForXrays())
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 2168, in generateArray
 0:16.01     condition, specData, doIdArrays)
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 1946, in generatePrefableArray
 0:16.01     specs.append(specTemplate % getDataTuple(member))
 0:16.01   File "/home/nikhil/mozilla-central-fetch/dom/bindings/Codegen.py", line 2148, in specData
 0:16.01     accessor)
 0:16.01 TypeError: fetch returns a Promise but needs special generic ops?
Yeah, we just need to add the support for this; I didn't add it initially when landing the Promise stuff because we had no consumers at the time.

Do you want to try doing it, or should I do it?
Flags: needinfo?(nsm.nikhil)
Assignee: nobody → nsm.nikhil
Flags: needinfo?(nsm.nikhil)
Do I need to preserve the callee the way GenericPromiseReturningBindingMethod does?
In that case, where do I put the code to preserve the callee in Codegen.py?
Attachment #8438036 - Flags: review?(bzbarsky)
Comment on attachment 8438036 [details] [diff] [review]
Add support for Promise returning methods on globals.

> Do I need to preserve the callee the way GenericPromiseReturningBindingMethod
> does?

Yes, because CallArgs stores callee and rval in the same place.  So once someone does rval() you can't even do args.callee() without asserting...

> In that case, where do I put the code to preserve the callee in Codegen.py?

Putting it at the top of your new generate_code output and also at the top of the unwrapFailureCode block should work fine, I expect.

>+                                             args.rval());\n"""%

Space before '%', please.

r=me with the nits fixed and the callee/rval thing addressed.
Attachment #8438036 - Flags: review?(bzbarsky) → review+
As discussed on IRC, we agreed to use the callArgs to save the callee right at the beginning of the function to avoid any "should work fine, I expect" moments!
https://hg.mozilla.org/mozilla-central/rev/65cc7e651827
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.