1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29

content / test / data / loader / cors_file_origin_test.html [blame]

<html>
<script>
const queryMap = {};
for (const item of location.search.substr(1).split('&')) {
  const [key, value] = item.split('=');
  queryMap[key] = value;
}

const test_url = queryMap.url + '?allow=' + queryMap.allow;

function finish(result) { document.title = result; }

const xhr = new XMLHttpRequest();
xhr.open('GET', test_url);
xhr.setRequestHeader('X-NotSimple', 'true');
xhr.addEventListener('error', e => {
  finish('FAIL');
});
xhr.addEventListener('load', e => {
  console.log('status = ' + xhr.status);
  if (xhr.response !== queryMap.response_text &&
      queryMap.response_text !== 'unused') {
    return finish('FAIL: response text does not match');
  }
  finish('PASS');
});
xhr.send();
</script>
</html>