https://github.com/web-platform-tests/wpt
Raw File
Tip revision: e58b9b6c5ed4a0846aea6de7366a492d627f0c12 authored by Robin Berjon on 10 April 2014, 17:37:03 UTC
the HTTP interface expects a date, not a string containing a date
Tip revision: e58b9b6
overridemimetype-headers-received-state-force-shiftjis.htm
<!doctype html>
<html>
  <head>
    <title>XMLHttpRequest: overrideMimeType() in HEADERS RECEIVED state, enforcing Shift-JIS encoding</title>
    <meta charset="utf-8">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-overridemimetype()-method" data-tested-assertations="/following::ol/li[1] /following::ol/li[4]" />
  </head>
  <body>
    <div id="log"></div>
    <script>
      var test = async_test();
      var client = new XMLHttpRequest();
      var readyState2Reached = false;
      client.onreadystatechange = test.step_func( function() {
        if(client.readyState===2){
          readyState2Reached = true;
          try{
            client.overrideMimeType('text/plain;charset=Shift-JIS');
          }catch(e){
            assert_unreached('overrideMimeType should not throw in state 2');
          }
        }
        if (client.readyState !== 4) return;
        assert_equals( readyState2Reached, true, "readyState = 2 event fired" );
        assert_equals( client.responseText, 'ใƒ†ใ‚นใƒˆ', 'overrideMimeType() in HEADERS RECEIVED state set encoding' );
        test.done();
      });
      client.open("GET", "resources/status.py?type="+encodeURIComponent('text/html;charset=UTF-8')+'&content=%83%65%83%58%83%67');
      client.send( '' );
    </script>
  </body>
</html>
back to top