usb_test(() => { return navigator.usb.requestDevice({ filters: [] })
.then(device => {
assert_unreachable('requestDevice should reject without a user gesture');
})
.catch(error => {
assert_equals(error.code, DOMException.SECURITY_ERR);
});
}, 'requestDevice rejects when called without a user gesture');
usb_test(() => { return callWithTrustedClick(() => navigator.usb.requestDevice({ filters: [] })
.then(device => {
assert_unreachable('requestDevice should reject when no device selected');
})
.catch(error => {
assert_equals(error.code, DOMException.NOT_FOUND_ERR);
})
);
}, 'requestDevice rejects when no device is chosen');
assert_equals(event.filters.length, expectedFilters.length); for (var i = 0; i < event.filters.length; ++i) {
assert_object_equals(event.filters[i], expectedFilters[i]);
}
assert_equals(event.exclusionFilters.length, expectedFilters.length); for (var i = 0; i < event.exclusionFilters.length; ++i) {
assert_object_equals(event.exclusionFilters[i], expectedFilters[i]);
}
event.respondWith(null);
};
const filters = expectedFilters; const exclusionFilters = expectedFilters; return callWithTrustedClick(() => { return navigator.usb.requestDevice({ filters, exclusionFilters })
.then(device => {
assert_unreached( 'requestDevice should reject because no device selected');
})
.catch(error => {
assert_equals(error.code, DOMException.NOT_FOUND_ERR);
});
});
}, 'filters are sent correctly');
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.