Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / netinfo / unregister-during-event.html
blob7325f8827ef799baa3e5f50352c90bdbc75eaa07
1 <!DOCTYPE html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 <script src="resources/netinfo_common.js"></script>
5 </head>
6 <body>
7 <script>
9 description("Tests that it's okay to unregister the event listener while handling the event.");
11 shouldBe('typeof window.internals.observeGC', '"function"',
12 'this test requires window.internals');
14 var otherHandler = function(e) {
15 shouldBe('connection.type', 'initialType');
16 shouldBe('connection.downlinkMax', 'initialDownlinkMax');
18 finishJSTest();
21 var handler = function(e) {
22 shouldBe('connection.type', 'newConnectionType');
23 shouldBe('connection.downlinkMax', 'newDownlinkMax');
24 connection.removeEventListener('change', handler);
25 connection.addEventListener('change', otherHandler);
26 internals.setNetworkConnectionInfo(initialType, initialDownlinkMax);
29 connection.addEventListener('change', handler);
30 internals.setNetworkConnectionInfo(newConnectionType, newDownlinkMax);
32 </script>
33 </body>
34 </html>