Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="application/javascript" src="head.js"></script> |
michael@0 | 7 | <script type="application/javascript" src="pc.js"></script> |
michael@0 | 8 | <script type="application/javascript" src="templates.js"></script> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <pre id="test"> |
michael@0 | 12 | <script type="application/javascript"> |
michael@0 | 13 | createHTML({ |
michael@0 | 14 | bug: "827843", |
michael@0 | 15 | title: "Ensure that localDescription and remoteDescription are null after close" |
michael@0 | 16 | }); |
michael@0 | 17 | |
michael@0 | 18 | var steps = [ |
michael@0 | 19 | [ |
michael@0 | 20 | "CHECK_FOR_SANE_SDP", |
michael@0 | 21 | function (test) { |
michael@0 | 22 | // TODO: We might want to move those checks into the default chain |
michael@0 | 23 | ok(test.pcLocal.localDescription, |
michael@0 | 24 | "test.pcLocal.localDescription is not null"); |
michael@0 | 25 | is(test.pcLocal.localDescription.type, "offer", |
michael@0 | 26 | "test.pcLocal.localDescription type is offer"); |
michael@0 | 27 | ok(test.pcLocal.localDescription.sdp.length > 10, |
michael@0 | 28 | "test.pcLocal.localDescription body length is plausible"); |
michael@0 | 29 | |
michael@0 | 30 | ok(test.pcLocal.remoteDescription, |
michael@0 | 31 | "test.pcLocal.remoteDescription is not null"); |
michael@0 | 32 | is(test.pcLocal.remoteDescription.type, "answer", |
michael@0 | 33 | "test.pcLocal.remoteDescription type is answer"); |
michael@0 | 34 | ok(test.pcLocal.remoteDescription.sdp.length > 10, |
michael@0 | 35 | "test.pcLocal.remoteDescription body length is plausible"); |
michael@0 | 36 | |
michael@0 | 37 | ok(test.pcRemote.localDescription, |
michael@0 | 38 | "test.pcRemote.localDescription is not null"); |
michael@0 | 39 | is(test.pcRemote.localDescription.type, "answer", |
michael@0 | 40 | "test.pcRemote.localDescription type is answer"); |
michael@0 | 41 | ok(test.pcRemote.localDescription.sdp.length > 10, |
michael@0 | 42 | "test.pcRemote.localDescription body length is plausible"); |
michael@0 | 43 | |
michael@0 | 44 | ok(test.pcRemote.remoteDescription, |
michael@0 | 45 | "test.pcRemote.remoteDescription is not null"); |
michael@0 | 46 | is(test.pcRemote.remoteDescription.type, "offer", |
michael@0 | 47 | "test.pcRemote.remoteDescription type is offer"); |
michael@0 | 48 | ok(test.pcRemote.remoteDescription.sdp.length > 10, |
michael@0 | 49 | "test.pcRemote.remoteDescription body length is plausible"); |
michael@0 | 50 | |
michael@0 | 51 | test.next(); |
michael@0 | 52 | } |
michael@0 | 53 | ], [ |
michael@0 | 54 | "CHECK_SDP_ON_CLOSED_PC", |
michael@0 | 55 | function (test) { |
michael@0 | 56 | var description; |
michael@0 | 57 | var exception = null; |
michael@0 | 58 | |
michael@0 | 59 | // handle the event which the close() triggers |
michael@0 | 60 | test.pcLocal.onsignalingstatechange = function (state) { |
michael@0 | 61 | is(state, "closed", "Received expected onsignalingstatechange event 'closed'"); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | test.pcLocal.close(); |
michael@0 | 65 | |
michael@0 | 66 | try { description = test.pcLocal.localDescription; } catch (e) { exception = e; } |
michael@0 | 67 | ok(exception, "Attempt to access localDescription of pcLocal after close throws exception"); |
michael@0 | 68 | exception = null; |
michael@0 | 69 | |
michael@0 | 70 | try { description = test.pcLocal.remoteDescription; } catch (e) { exception = e; } |
michael@0 | 71 | ok(exception, "Attempt to access remoteDescription of pcLocal after close throws exception"); |
michael@0 | 72 | exception = null; |
michael@0 | 73 | |
michael@0 | 74 | // handle the event which the close() triggers |
michael@0 | 75 | test.pcRemote.onsignalingstatechange = function (state) { |
michael@0 | 76 | is(state, "closed", "Received expected onsignalingstatechange event 'closed'"); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | test.pcRemote.close(); |
michael@0 | 80 | |
michael@0 | 81 | try { description = test.pcRemote.localDescription; } catch (e) { exception = e; } |
michael@0 | 82 | ok(exception, "Attempt to access localDescription of pcRemote after close throws exception"); |
michael@0 | 83 | exception = null; |
michael@0 | 84 | |
michael@0 | 85 | try { description = test.pcRemote.remoteDescription; } catch (e) { exception = e; } |
michael@0 | 86 | ok(exception, "Attempt to access remoteDescription of pcRemote after close throws exception"); |
michael@0 | 87 | |
michael@0 | 88 | test.next(); |
michael@0 | 89 | } |
michael@0 | 90 | ] |
michael@0 | 91 | ]; |
michael@0 | 92 | |
michael@0 | 93 | var test; |
michael@0 | 94 | runTest(function () { |
michael@0 | 95 | test = new PeerConnectionTest(); |
michael@0 | 96 | test.setMediaConstraints([{audio: true}], [{audio: true}]); |
michael@0 | 97 | test.chain.append(steps); |
michael@0 | 98 | test.run(); |
michael@0 | 99 | }); |
michael@0 | 100 | </script> |
michael@0 | 101 | </pre> |
michael@0 | 102 | </body> |
michael@0 | 103 | </html> |