Stop using NS_ERROR_DOM_TYPE_ERR in payments code
Categories
(Core :: DOM: Web Payments, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox75 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: edenchuang)
References
Details
Attachments
(1 file)
PaymentRequest::Constructor has:
RefPtr<PaymentRequest> request;
nsresult rv = manager->CreatePayment(aGlobal.Context(), window,
topLevelPrincipal, aMethodData, aDetails,
aOptions, getter_AddRefs(request));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
I don't know what spec step this corresponds to and why the error-throwing is not done on an ErrorResult in CreatePayment, but this code is wrong: there's never a time when throwing NS_ERROR_DOM_TYPE_ERR is the right thing to do. If a TypeError is supposed to be thrown, that needs to use ThrowTypeError.
It doesn't seem like there's any test coverage for this, by the way. Certainly https://coverage.moz.tools/#revision=latest&path=dom%2Fpayments%2FPaymentRequest.cpp&view=file claims this code (as well as many other error-handling cases in PaymentRequest::Constructor, including ones that are easily testable from JS) is not reached...
I can try to disentangle the error-reporting here, so I can make progress on bug 1581172, but it might be better if someone more familiar with this code took a look.
| Reporter | ||
Comment 2•6 years ago
|
||
No need to apologize, and thank you!
Updated•6 years ago
|
| Assignee | ||
Comment 3•6 years ago
|
||
Updated•6 years ago
|
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 5•6 years ago
|
||
| bugherder | ||
Description
•