tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

common.js (1558B)


      1 function createPassFail(condition, test, cleanup, cleanupParam) {
      2    var div = document.querySelector("#passfail")
      3    var para = document.createElement("p")
      4    var pass = document.createElement("button")
      5    var fail = document.createElement("button")
      6    var style = "font-family: monospace"
      7    para.innerHTML = condition
      8        + ', press the PASS button;'
      9        + ' otherwise press the FAIL button.',
     10    pass.innerHTML = "PASS"
     11    fail.innerHTML = "FAIL"
     12    pass.setAttribute("style", style)
     13    fail.setAttribute("style", style)
     14    pass.addEventListener("click", function () {
     15        clearPassFail()
     16        cleanup(cleanupParam)
     17        test.done()
     18    }, false)
     19    fail.addEventListener("click", function () {
     20        clearPassFail()
     21        cleanup(cleanupParam)
     22        test.force_timeout()
     23        test.set_status(test.FAIL)
     24        test.done()
     25    }, false)
     26    document.body.appendChild(div)
     27    div.appendChild(para)
     28    div.appendChild(pass)
     29    div.appendChild(fail)
     30 }
     31 function clearPassFail() {
     32    document.querySelector("#passfail").innerHTML = ""
     33 }
     34 function closeNotifications(notifications) {
     35    for (var i=0; i < notifications.length; i++) {
     36        notifications[i].close()
     37    }
     38 }
     39 function hasNotificationPermission() {
     40    Notification.requestPermission()
     41    if (Notification.permission != "granted") {
     42        alert("TEST NOT RUN. Change your browser settings so that"
     43            + " notifications for this origin are allowed, and then re-run"
     44            + " this test.")
     45        return false
     46    }
     47    return true
     48 }