function promise_rejects_dom(test, type, promiseOrConstructor, descriptionOrPromise, maybeDescription) {
        let constructor, promise, description;
        if (typeof promiseOrConstructor === "function" &&
            promiseOrConstructor.name === "DOMException") {
            constructor = promiseOrConstructor;
            promise = descriptionOrPromise;
            description = maybeDescription;
        } else {
            constructor = self.DOMException;
            promise = promiseOrConstructor;
            description = descriptionOrPromise;
            assert(maybeDescription === undefined,
                   "Too many args passed to no-constructor version of promise_rejects_dom, or accidentally explicitly passed undefined");
        }
        return bring_promise_to_current_realm(promise)
            .then(test.unreached_func("Should have rejected: " + description))
            .catch(function(e) {
                assert_throws_dom_impl(type, function() { throw e; }, description,
                                       "promise_rejects_dom", constructor);
            });
    }
Assert that a Promise is rejected with the right DOMException.

For the remaining arguments, there are two ways of calling
promise_rejects_dom:

1) If the DOMException is expected to come from the current global, the
third argument should be the promise expected to reject, and a fourth,
optional, argument is the assertion description.

2) If the DOMException is expected to come from some other global, the
third argument should be the DOMException constructor from that global,
the fourth argument the promise expected to reject, and the fifth,
optional, argument the assertion description.

@param {Test} test - the `Test` to use for the assertion.
@param {number|string} type - See documentation for
`assert_throws_dom <#assert_throws_dom>`_.
@param {Function} promiseOrConstructor - Either the constructor
for the expected exception (if the exception comes from another
global), or the promise that's expected to reject (if the
exception comes from the current global).
@param {Function|string} descriptionOrPromise - Either the
promise that's expected to reject (if the exception comes from
another global), or the optional description of the condition
being tested (if the exception comes from the current global).
@param {string} [description] - Description of the condition
being tested (if the exception comes from another global).