| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="resources/promise-utils.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Verify that the RTCPeerConnection JS built-in methods check calling 'this'"); |
| |
| const reason = "TypeError: Function should be called on an RTCPeerConnection"; |
| |
| function Foo() {} |
| Foo.prototype = RTCPeerConnection.prototype; |
| let objectWithPcPrototype = new Foo(); |
| |
| promiseShouldReject("RTCPeerConnection.prototype.createOffer.call({})", "reason") |
| .then(() => promiseShouldReject("RTCPeerConnection.prototype.createAnswer.call({})", "reason")) |
| .then(() => promiseShouldReject("RTCPeerConnection.prototype.setLocalDescription.call({})", "reason")) |
| .then(() => promiseShouldReject("RTCPeerConnection.prototype.setRemoteDescription.call({})", "reason")) |
| .then(() => promiseShouldReject("RTCPeerConnection.prototype.addIceCandidate.call({})", "reason")) |
| .then(() => promiseShouldReject("RTCPeerConnection.prototype.getStats.call({}, null)", "reason")) |
| |
| .then(() => promiseShouldReject("objectWithPcPrototype.createOffer()", "reason")) |
| .then(() => promiseShouldReject("objectWithPcPrototype.createAnswer()", "reason")) |
| .then(() => promiseShouldReject("objectWithPcPrototype.setLocalDescription()", "reason")) |
| .then(() => promiseShouldReject("objectWithPcPrototype.setRemoteDescription()", "reason")) |
| .then(() => promiseShouldReject("objectWithPcPrototype.addIceCandidate()", "reason")) |
| .then(() => promiseShouldReject("objectWithPcPrototype.getStats()", "reason")) |
| |
| .then(() => { |
| testPassed("End of test promise chain"); |
| finishJSTest(); |
| }) |
| .catch(error => { |
| testFailed("Error in promise chain: " + error); |
| finishJSTest(); |
| }); |
| |
| window.jsTestIsAsync = true; |
| window.successfullyParsed = true; |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |