Guest User

quick fix SE Net-login-test-page

a guest
Apr 15th, 2018
164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function runTests(e) {
  2.   function t(e) {
  3.     window.attachEvent ? window.attachEvent("onmessage", e) : window.addEventListener("message", e, !1)
  4.   }
  5.  
  6.   function n(e) {
  7.     var t = $("#" + e.element);
  8.     t.find(".success")
  9.       .show(), t.find(".status")
  10.       .html("<b style='color:green'>ok</b>")
  11.   }
  12.  
  13.   function i(e) {
  14.     var t = $("#" + e.element);
  15.     t.find(".failure")
  16.       .show(), t.find(".status")
  17.       .html("<b style='color:red'>failed</b>")
  18.   }
  19.  
  20.   function r(e, t) {
  21.     var n = $("#" + e.element);
  22.     n.find(".status")
  23.       .html("<b style='color:red'>skipped</b>"), $("<p>" + function(e) {
  24.         return 1 == e.failedName, "This test requires " + e.failedName + " to work."
  25.       }({
  26.         "failedName": t
  27.       }) + "</p>")
  28.       .appendTo(n)
  29.   }
  30.  
  31.   function a() {
  32.     if(0 == d.length) return f.length == p ? $("#all-is-well")
  33.       .show() : $("#houston-we-have-a-problem")
  34.       .show(), void 0;
  35.     var e, t = d.shift(),
  36.       o = !0;
  37.     for(var s in t.requires) - 1 == $.inArray(t.requires[s], f) && (o = !1, e = t.requires[s].name);
  38.     return $("#" + t.element)
  39.       .show(), o ? (t.failure = function() {
  40.         i(this), a()
  41.       }, t.success = function() {
  42.         n(this), f.push(this), a()
  43.       }, t.run(), void 0) : (r(t, e), a())
  44.   }
  45.   var o = {
  46.     "name": "JavaScript",
  47.     "requires": [],
  48.     "element": "test-javascript"
  49.   };
  50.   o.run = function() {
  51.     this.success()
  52.   };
  53.   var s = {
  54.     "name": "cookies",
  55.     "requires": [],
  56.     "element": "test-cookie"
  57.   };
  58.   s.run = function() {
  59.     var e = $.cookie("have_a_cookie");
  60.     return $.cookie("have_a_cookie", null, {
  61.       "path": "/"
  62.     }), "and eat it" != e ? this.failure() : this.success()
  63.   };
  64.   var l = {
  65.     "name": "cross-document messaging",
  66.     "requires": [],
  67.     "element": "test-message"
  68.   };
  69.   l.run = function() {
  70.     function e(e) {
  71.       e.origin.replace(/^https:\/\/([^:\/]*).*$/, "$1") == document.domain && "I am a message" == e.data && (clearTimeout(i), n.success())
  72.     }
  73.     var n = this;
  74.     t(e);
  75.     var i = setTimeout(function() {
  76.       n.failure()
  77.     }, 2e3);
  78.     setTimeout(function() {
  79.       try {
  80.         window.postMessage("I am a message", window.location.href)
  81.       }
  82.       catch(e) {
  83.         clearTimeout(i), n.failure()
  84.       }
  85.     }, 200)
  86.   };
  87.   var c = {
  88.     "name": "DOM storage",
  89.     "requires": [],
  90.     "element": "test-storage"
  91.   };
  92.   c.run = function() {
  93.     var e = this;
  94.     try {
  95.       window.localStorage.setItem("lolcat", "IM IN UR BROWZER, STORNG UR ITEMS")
  96.     }
  97.     catch(t) {
  98.       return this.failure()
  99.     }
  100.     window.setTimeout(function() {
  101.       "IM IN UR BROWZER, STORNG UR ITEMS" == window.localStorage.getItem("lolcat") ? (window.localStorage.removeItem("lolcat"), e.success()) : e.failure()
  102.     }, 500)
  103.   };
  104.   var u = {
  105.     "name": "communication with StackAuth",
  106.     "requires": [l, c],
  107.     "element": "test-stackauth"
  108.   };
  109.   u.run = function() {
  110.     function n(t) {
  111.       t.origin == e && "login-test-success" == t.data && (clearTimeout(r), i.success())
  112.     }
  113.     var i = this,
  114.       r = setTimeout(function() {
  115.         i.failure()
  116.       }, 5e3);
  117.     t(n), $('<iframe src="' + e + '/login-test" style="border: 2px dotted silver;" width="700px"><code>&lt;iframe&gt;s</code> are not enabled in your browser</iframe>')
  118.       .insertAfter("#" + this.element + " h3")
  119.   };
  120.   var d = [o, s, l, c, u],
  121.     p = d.length,
  122.     f = [];
  123.   a()
  124. }
  125. runTests('https://stackauth.com')
RAW Paste Data