浏览代码

merged branch Seldaek/wdt (PR #1388)

Commits
-------

abd60ac [WebProfilerBundle] Do not display toolbar loading result if it's not a valid toolbar
406c8d8 [WebProfilerBundle] Make toolbar loading non-blocking

Discussion
----------

Non-blocking WDT & prevents garbage to slip in the page

I made the loading non-blocking so that it's not preventing normal operation of the page when the WDT takes a bit long to come up (happens sometimes when the machine is busy).

The second commit also checks that the response looks correct, to prevent stack traces and such to appear in the page if there was a problem. The main issue is not really stack traces though it's mostly with security and intercept_redirect enabled, if you look at a fully secured site you get twice the redirect intercept message to the login page.

Tested in IE7/9/FF4/Opera11
Fabien Potencier 14 年之前
父节点
当前提交
8541a5bcbc
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

+ 7 - 3
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

@@ -8,10 +8,14 @@
         } else {
             xhr = new ActiveXObject('Microsoft.XMLHTTP');
         }
-        xhr.open('GET', '{{ path("_wdt", { "token": token }) }}', false);
+        xhr.open('GET', '{{ path("_wdt", { "token": token }) }}', true);
         xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+        xhr.onreadystatechange = function(state) {
+            if (4 === xhr.readyState && 200 === xhr.status && '<!-- START' === xhr.responseText.substring(0, 10)) {
+                wdt.innerHTML = xhr.responseText;
+                wdt.style.display = 'block';
+            }
+        };
         xhr.send('');
-        wdt.innerHTML = xhr.responseText;
-        wdt.style.display = 'block';
     })();
 /*]]>*/</script>