detection-getSupportedFormats.https.html (1095B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://wicg.github.io/shape-detection-api/#dom-barcodedetector-getsupportedformats"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/shapedetection-helpers.js"></script> 6 <script> 7 8 detection_test('BarcodeDetectionTest', async t => { 9 const result = await BarcodeDetector.getSupportedFormats(); 10 assert_equals(result.length, 3, 'Number of supported formats'); 11 assert_equals(result[0], 'aztec', 'format 1'); 12 assert_equals(result[1], 'data_matrix', 'format 2'); 13 assert_equals(result[2], 'qr_code', 'format 3'); 14 }, 'get supported barcode formats'); 15 16 detection_test('BarcodeDetectionTest', async (t, detectionTest) => { 17 // Disable built-in support for barcode detection to test fallback handling. 18 detectionTest.MockBarcodeDetectionProvider().simulateNoImplementation(); 19 20 const result = await BarcodeDetector.getSupportedFormats(); 21 assert_equals(result.length, 0, 'result.length'); 22 23 }, 'getSupportedFormats() resolves with empty list when unsupported'); 24 25 </script>