| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="../http/tests/resources/permissions-helper.js"></script> | 5 <script src="../http/tests/resources/permissions-helper.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 description("Tests navigator.requestMIDIAccess."); | 9 description("Tests navigator.requestMIDIAccess."); |
| 10 | 10 |
| 11 shouldBeDefined("PermissionsHelper.setPermission"); | 11 shouldBeDefined("PermissionsHelper.setPermission"); |
| 12 | 12 |
| 13 var access; | 13 var access; |
| 14 var input; | 14 var input; |
| 15 var output; | 15 var output; |
| 16 | 16 |
| 17 function checkInputMap(inputs) { | 17 function checkInputMap(inputs) { |
| 18 window.inputs = inputs; | 18 window.inputs = inputs; |
| 19 debug("for (var input of inputs.values())"); | 19 debug("for (var input of inputs.values())"); |
| 20 for (var input of inputs.values()) { | 20 for (var input of inputs.values()) { |
| 21 window.input = input; | 21 window.input = input; |
| 22 shouldBeEqualToString("input.id", "MockInputID"); | 22 shouldBeEqualToString("input.id", "MockInputID-0"); |
| 23 shouldBeEqualToString("input.manufacturer", "MockInputManufacturer"); | 23 shouldBeEqualToString("input.manufacturer", "MockInputManufacturer"); |
| 24 shouldBeEqualToString("input.name", "MockInputName"); | 24 shouldBeEqualToString("input.name", "MockInputName"); |
| 25 shouldBeEqualToString("input.version", "MockInputVersion"); | 25 shouldBeEqualToString("input.version", "MockInputVersion"); |
| 26 shouldBeEqualToString("input.state", "connected"); | 26 shouldBeEqualToString("input.state", "connected"); |
| 27 shouldBeEqualToString("input.type", "input"); | 27 shouldBeEqualToString("input.type", "input"); |
| 28 } | 28 } |
| 29 debug("for (var input of inputs.keys())"); | 29 debug("for (var input of inputs.keys())"); |
| 30 for (var key of inputs.keys()) { | 30 for (var key of inputs.keys()) { |
| 31 window.inputKey = key; | 31 window.inputKey = key; |
| 32 shouldBeEqualToString("inputKey", "MockInputID"); | 32 shouldBeEqualToString("inputKey", "MockInputID-0"); |
| 33 } | 33 } |
| 34 debug("for (var input of inputs.entries())"); | 34 debug("for (var input of inputs.entries())"); |
| 35 for (var entry of inputs.entries()) { | 35 for (var entry of inputs.entries()) { |
| 36 window.entry = entry; | 36 window.entry = entry; |
| 37 shouldBe("entry[0]", "inputKey"); | 37 shouldBe("entry[0]", "inputKey"); |
| 38 shouldBe("entry[1]", "input"); | 38 shouldBe("entry[1]", "input"); |
| 39 } | 39 } |
| 40 debug("for (var input of inputs)"); | 40 debug("for (var input of inputs)"); |
| 41 for (var entry of inputs) { | 41 for (var entry of inputs) { |
| 42 window.entry = entry; | 42 window.entry = entry; |
| 43 shouldBe("entry[0]", "inputKey"); | 43 shouldBe("entry[0]", "inputKey"); |
| 44 shouldBe("entry[1]", "input"); | 44 shouldBe("entry[1]", "input"); |
| 45 } | 45 } |
| 46 shouldBeTrue("inputs.has('MockInputID')"); | 46 shouldBeTrue("inputs.has('MockInputID-0')"); |
| 47 shouldBeFalse("inputs.has('MockOutputID')"); | 47 shouldBeFalse("inputs.has('MockOutputID-0')"); |
| 48 shouldBe("inputs.get('MockInputID')", "input"); | 48 shouldBe("inputs.get('MockInputID-0')", "input"); |
| 49 shouldBeUndefined("inputs.get('MockOutputID')"); | 49 shouldBeUndefined("inputs.get('MockOutputID-0')"); |
| 50 debug("inputs.forEach(...)"); | 50 debug("inputs.forEach(...)"); |
| 51 inputs.forEach(function (input, key, map) { | 51 inputs.forEach(function (input, key, map) { |
| 52 window.forEachInput = input; | 52 window.forEachInput = input; |
| 53 shouldBe("forEachInput", "input"); | 53 shouldBe("forEachInput", "input"); |
| 54 window.forEachInputKey = key; | 54 window.forEachInputKey = key; |
| 55 shouldBe("forEachInputKey", "inputKey"); | 55 shouldBe("forEachInputKey", "inputKey"); |
| 56 window.forEachMap = map; | 56 window.forEachMap = map; |
| 57 shouldBe("forEachMap", "inputs"); | 57 shouldBe("forEachMap", "inputs"); |
| 58 }); | 58 }); |
| 59 } | 59 } |
| 60 | 60 |
| 61 function checkOutputMap(outputs) { | 61 function checkOutputMap(outputs) { |
| 62 window.outputs = outputs; | 62 window.outputs = outputs; |
| 63 debug("for (var output of outputs.values())"); | 63 debug("for (var output of outputs.values())"); |
| 64 for (var output of outputs.values()) { | 64 for (var output of outputs.values()) { |
| 65 window.output = output; | 65 window.output = output; |
| 66 shouldBeEqualToString("output.id", "MockOutputID"); | 66 shouldBeEqualToString("output.id", "MockOutputID-0"); |
| 67 shouldBeEqualToString("output.manufacturer", "MockOutputManufacturer"); | 67 shouldBeEqualToString("output.manufacturer", "MockOutputManufacturer"); |
| 68 shouldBeEqualToString("output.name", "MockOutputName"); | 68 shouldBeEqualToString("output.name", "MockOutputName"); |
| 69 shouldBeEqualToString("output.version", "MockOutputVersion"); | 69 shouldBeEqualToString("output.version", "MockOutputVersion"); |
| 70 shouldBeEqualToString("output.state", "connected"); | 70 shouldBeEqualToString("output.state", "connected"); |
| 71 shouldBeEqualToString("output.type", "output"); | 71 shouldBeEqualToString("output.type", "output"); |
| 72 } | 72 } |
| 73 debug("for (var output of outputs.keys())"); | 73 debug("for (var output of outputs.keys())"); |
| 74 for (var key of outputs.keys()) { | 74 for (var key of outputs.keys()) { |
| 75 window.outputKey = key; | 75 window.outputKey = key; |
| 76 shouldBeEqualToString("outputKey", "MockOutputID"); | 76 shouldBeEqualToString("outputKey", "MockOutputID-0"); |
| 77 } | 77 } |
| 78 debug("for (var output of outputs.entries())"); | 78 debug("for (var output of outputs.entries())"); |
| 79 for (var entry of outputs.entries()) { | 79 for (var entry of outputs.entries()) { |
| 80 window.entry = entry; | 80 window.entry = entry; |
| 81 shouldBe("entry[0]", "outputKey"); | 81 shouldBe("entry[0]", "outputKey"); |
| 82 shouldBe("entry[1]", "output"); | 82 shouldBe("entry[1]", "output"); |
| 83 } | 83 } |
| 84 debug("for (var output of outputs)"); | 84 debug("for (var output of outputs)"); |
| 85 for (var entry of outputs) { | 85 for (var entry of outputs) { |
| 86 window.entry = entry; | 86 window.entry = entry; |
| 87 shouldBe("entry[0]", "outputKey"); | 87 shouldBe("entry[0]", "outputKey"); |
| 88 shouldBe("entry[1]", "output"); | 88 shouldBe("entry[1]", "output"); |
| 89 } | 89 } |
| 90 shouldBeTrue("outputs.has('MockOutputID')"); | 90 shouldBeTrue("outputs.has('MockOutputID-0')"); |
| 91 shouldBeFalse("outputs.has('MockInputID')"); | 91 shouldBeFalse("outputs.has('MockInputID-0')"); |
| 92 shouldBe("outputs.get('MockOutputID')", "output"); | 92 shouldBe("outputs.get('MockOutputID-0')", "output"); |
| 93 shouldBeUndefined("outputs.get('MockInputID')"); | 93 shouldBeUndefined("outputs.get('MockInputID-0')"); |
| 94 debug("outputs.forEach(...)"); | 94 debug("outputs.forEach(...)"); |
| 95 outputs.forEach(function (output, key, map) { | 95 outputs.forEach(function (output, key, map) { |
| 96 window.forEachOutput = output; | 96 window.forEachOutput = output; |
| 97 shouldBe("forEachOutput", "output"); | 97 shouldBe("forEachOutput", "output"); |
| 98 window.forEachOutputKey = key; | 98 window.forEachOutputKey = key; |
| 99 shouldBe("forEachOutputKey", "outputKey"); | 99 shouldBe("forEachOutputKey", "outputKey"); |
| 100 window.forEachMap = map; | 100 window.forEachMap = map; |
| 101 shouldBe("forEachMap", "outputs"); | 101 shouldBe("forEachMap", "outputs"); |
| 102 }); | 102 }); |
| 103 } | 103 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Set default permission behavior that grants non-sysex requests. | 158 // Set default permission behavior that grants non-sysex requests. |
| 159 PermissionsHelper.setPermission('midi', 'granted').then(function() { | 159 PermissionsHelper.setPermission('midi', 'granted').then(function() { |
| 160 // Test basic access, with no System Exclusive. | 160 // Test basic access, with no System Exclusive. |
| 161 navigator.requestMIDIAccess().then(successCallback1, errorCallback1); | 161 navigator.requestMIDIAccess().then(successCallback1, errorCallback1); |
| 162 }); | 162 }); |
| 163 | 163 |
| 164 </script> | 164 </script> |
| 165 </body> | 165 </body> |
| 166 </html> | 166 </html> |
| OLD | NEW |