Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/base/test/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 6 kB image not shown  

Quelle  test_bug475156.html   Sprache: HTML

 
 products/sources/formale Sprachen/C/Firefox/dom/base/test/test_bug475156.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=475156
-->

<head>
  <title>Test for Bug 475156</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="drive(tests.shift());">
<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

var path = "http://mochi.test:8888/tests/dom/base/test/";

function fromCache(xhr)
{
  var ch = SpecialPowers.wrap(xhr).channel.QueryInterface(SpecialPowers.Ci.nsICacheInfoChannel);
  return ch.isFromCache();  
}

var tests = [
  // First just init the file with an ETag
  {
    init(xhr) 
    {
      xhr.open("GET", path + "bug475156.sjs?etag=a1");
    },
    
    loading(xhr)
    {
    },

    done(xhr)
    {
    },
  },

  // Try to load the file the first time regularly, we have to get 200 OK
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
    },

    loading(xhr)
    {
      is(fromCache(xhr), false, "Not coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We get a fresh version of the file");
      is(xhr.getResponseHeader("Etag"), "a1""We got correct ETag");
      is(xhr.responseText, "a1""We got the expected file body");
    },
  },

  // Try to load the file the second time regularly, we have to get 304 Not Modified
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a1");
    },

    loading(xhr)
    {
      is(fromCache(xhr), true, "Coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We got cached version");
      is(xhr.getResponseHeader("Etag"), "a1""We got correct ETag");
      is(xhr.responseText, "a1""We got the expected file body");
    },
  },

  // Try to load the file the third time regularly, we have to get 304 Not Modified
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a1");
    },

    loading(xhr)
    {
      is(fromCache(xhr), true, "Coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We got cached version");
      is(xhr.getResponseHeader("Etag"), "a1""We got correct ETag");
      is(xhr.responseText, "a1""We got the expected file body");
    },
  },

  // Now modify the ETag
  {
    init(xhr) 
    {
      xhr.open("GET", path + "bug475156.sjs?etag=a2");
    },

    loading(xhr)
    {
    },

    done(xhr)
    {
    },
  },

  // Try to load the file, we have to get 200 OK with the new content
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a2");
    },

    loading(xhr)
    {
      is(fromCache(xhr), false, "Not coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We get a fresh version of the file");
      is(xhr.getResponseHeader("Etag"), "a2""We got correct ETag");
      is(xhr.responseText, "a2""We got the expected file body");
    },
  },

  // Try to load the file the second time regularly, we have to get 304 Not Modified
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a2");
    },

    loading(xhr)
    {
      is(fromCache(xhr), true, "Coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We got cached version");
      is(xhr.getResponseHeader("Etag"), "a2""We got correct ETag");
      is(xhr.responseText, "a2""We got the expected file body");
    },
  },

  // Try to load the file the third time regularly, we have to get 304 Not Modified
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a2");
    },

    loading(xhr)
    {
      is(fromCache(xhr), true, "Coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We got cached version");
      is(xhr.getResponseHeader("Etag"), "a2""We got correct ETag");
      is(xhr.responseText, "a2""We got the expected file body");
    },
  },

  // Now modify the ETag ones more
  {
    init(xhr) 
    {
      xhr.open("GET", path + "bug475156.sjs?etag=a3");
    },

    loading(xhr)
    {
    },

    done(xhr)
    {
    },
  },

  // Try to load the file, we have to get 200 OK with the new content
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a3");
    },

    loading(xhr)
    {
      is(fromCache(xhr), false, "Not coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We get a fresh version of the file");
      is(xhr.getResponseHeader("Etag"), "a3""We got correct ETag");
      is(xhr.responseText, "a3""We got the expected file body");
    },
  },

  // Try to load the file the second time regularly, we have to get 304 Not Modified
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a3");
    },

    loading(xhr)
    {
      is(fromCache(xhr), true, "Coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We got cached version");
      is(xhr.getResponseHeader("Etag"), "a3""We got correct ETag");
      is(xhr.responseText, "a3""We got the expected file body");
    },
  },

  // Try to load the file the third time regularly, we have to get 304 Not Modified
  {    
    init(xhr)
    {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a3");
    },

    loading(xhr)
    {
      is(fromCache(xhr), true, "Coming from the cache");
    },

    done(xhr)
    {
      is(xhr.status, 200, "We got cached version");
      is(xhr.getResponseHeader("Etag"), "a3""We got correct ETag");
      is(xhr.responseText, "a3""We got the expected file body");
    },
  },

  // Load one last time to reset the state variable in the .sjs file
  {
    init (xhr) {
      xhr.open("GET", path + "bug475156.sjs");
      xhr.setRequestHeader("If-Match""a1");
    },

    loading (xhr) {
    },

    done (xhr) {
    },
  },
]


function drive(test)
{
  SpecialPowers.pushPrefEnv({set: [["network.http.rcwn.enabled", false]]}, _=>{
    var xhr = new XMLHttpRequest();
    test.init(xhr);
    xhr.onreadystatechange = function() {
      if (this.readyState == 3) {
        test.loading(this);
      }
      if (this.readyState == 4) {
        test.done(this);
        if (!tests.length)
          SimpleTest.finish();
        else
          drive(tests.shift());
      }
    }
    xhr.send();
  });
}

</script>
</body>
</html>


Messung V0.5
C=99 H=100 G=99

¤ Dauer der Verarbeitung: 0.23 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.