Revision 149c83d77d05dafea4a5a4dadf6670bfadc8e360 authored by moz-wptsync-bot on 16 March 2018, 13:38:52 UTC, committed by moz-wptsync-bot on 16 March 2018, 13:38:52 UTC
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1445883
gecko-commit: 0f81334efa0a008db8931a41eef2d26a77d0e800
gecko-integration-branch: mozilla-inbound
gecko-reviewers: smaug
1 parent 1cbb928
Raw File
workerxhr-origin-referrer.js
importScripts("/resources/testharness.js")

async_test(function() {
    var expected = 'Referer: ' +
                   location.href.replace(/[^/]*$/, '') +
                   "workerxhr-origin-referrer.js\n"

    var xhr = new XMLHttpRequest()
    xhr.onreadystatechange = this.step_func(function() {
        if (xhr.readyState == 4) {
            assert_equals(xhr.responseText, expected)
            this.done()
        }
    })
    xhr.open('GET', 'inspect-headers.py?filter_name=referer', true)
    xhr.send()
}, 'Referer header')

async_test(function() {
    var expected = 'Origin: ' +
                   location.protocol +
                   '//' +
                   location.hostname +
                   (location.port === "" ? "" : ":" + location.port) +
                   '\n'

    var xhr = new XMLHttpRequest()
    xhr.onreadystatechange = this.step_func(function() {
        if (xhr.readyState == 4) {
            assert_equals(xhr.responseText, expected)
            this.done()
        }
    })
    var url = location.protocol +
              '//www2.' +
              location.hostname +
              (location.port === "" ? "" : ":" + location.port) +
              location.pathname.replace(/[^/]*$/, '') +
              'inspect-headers.py?filter_name=origin&cors'
    xhr.open('GET', url, true)
    xhr.send()
}, 'Origin header')

async_test(function() {
    // If "origin" / base URL is the origin of this JS file, we can load files
    // from the server it originates from.. and requri.py will be able to tell us
    // what the requested URL was

    var expected = location.href.replace(/[^/]*$/, '') +
                   'requri.py?full'

    var xhr = new XMLHttpRequest()
    xhr.onreadystatechange = this.step_func(function() {
        if (xhr.readyState == 4) {
            assert_equals(xhr.responseText, expected)
            this.done()
        }
    })
    xhr.open('GET', 'requri.py?full', true)
    xhr.send()
}, 'Request URL test')

done()
back to top