Closed Bug 1610881 Opened 6 years ago Closed 6 years ago

Stop using NS_ERROR_DOM_TYPE_ERR in payments code

Categories

(Core :: DOM: Web Payments, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla75
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.

Flags: needinfo?(echuang)

Sorry, will be working on it.

Flags: needinfo?(echuang)

No need to apologize, and thank you!

Type: defect → task
Priority: -- → P3
Assignee: nobody → echuang
Status: NEW → ASSIGNED
Type: task → defect
Priority: P3 → --
Type: defect → task
Priority: -- → P3
Attachment #9124243 - Attachment description: Bug 1610881 - Get rid of ErrorResult.Throw(NS_ERROR_DOM_TYPE_ERR) and using ErrorResult from API directly → Bug 1610881 - Get rid of ErrorResult.Throw(DOMException) in Payment code
Pushed by cbrindusan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/03b87e4336e5 Get rid of ErrorResult.Throw(DOMException) in Payment code r=bzbarsky
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: