test_network_basics.html 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Test for Network API</title>
  5. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  6. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  7. </head>
  8. <body>
  9. <p id="display"></p>
  10. <div id="content" style="display: none">
  11. </div>
  12. <pre id="test">
  13. <script type="application/javascript">
  14. /** Test for Network Information API **/
  15. function test() {
  16. ok('connection' in navigator, "navigator.connection should exist");
  17. ok(navigator.connection, "navigator.connection returns an object");
  18. ok(navigator.connection instanceof EventTarget,
  19. "navigator.connection is a EventTarget object");
  20. ok('type' in navigator.connection,
  21. "type should be a Connection attribute");
  22. is(navigator.connection.type, "none",
  23. "By default connection.type equals to none");
  24. SimpleTest.finish();
  25. }
  26. SimpleTest.waitForExplicitFinish();
  27. SpecialPowers.pushPrefEnv({'set': [["dom.netinfo.enabled", true]]}, test);
  28. </script>
  29. </pre>
  30. </body>
  31. </html>