File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed
debug_toolbar/static/debug_toolbar/js Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -36,21 +36,24 @@ const $$ = {
36
36
37
37
function ajax ( url , init ) {
38
38
init = Object . assign ( { credentials : "same-origin" } , init ) ;
39
- return fetch ( url , init ) . then ( function ( response ) {
40
- if ( response . ok ) {
41
- return response . json ( ) ;
42
- } else {
39
+ return fetch ( url , init )
40
+ . then ( function ( response ) {
41
+ if ( response . ok ) {
42
+ return response . json ( ) ;
43
+ }
44
+ return Promise . reject (
45
+ new Error ( response . status + ": " + response . statusText )
46
+ ) ;
47
+ } )
48
+ . catch ( function ( error ) {
43
49
const win = document . querySelector ( "#djDebugWindow" ) ;
44
50
win . innerHTML =
45
51
'<div class="djDebugPanelTitle"><a class="djDebugClose" href="">»</a><h3>' +
46
- response . status +
47
- ": " +
48
- response . statusText +
52
+ error . message +
49
53
"</h3></div>" ;
50
54
$$ . show ( win ) ;
51
- return Promise . reject ( ) ;
52
- }
53
- } ) ;
55
+ throw error ;
56
+ } ) ;
54
57
}
55
58
56
59
function ajaxForm ( element ) {
Original file line number Diff line number Diff line change 12
12
from django .test .utils import override_settings
13
13
14
14
from debug_toolbar .middleware import DebugToolbarMiddleware , show_toolbar
15
+ from debug_toolbar .panels import Panel
15
16
from debug_toolbar .toolbar import DebugToolbar
16
17
17
18
from .base import BaseTestCase , IntegrationTestCase
31
32
rf = RequestFactory ()
32
33
33
34
35
+ class BuggyPanel (Panel ):
36
+ def title (self ):
37
+ return "BuggyPanel"
38
+
39
+ @property
40
+ def content (self ):
41
+ raise Exception
42
+
43
+
34
44
@override_settings (DEBUG = True )
35
45
class DebugToolbarTestCase (BaseTestCase ):
36
46
def test_show_toolbar (self ):
@@ -466,3 +476,11 @@ def test_sql_action_and_go_back(self):
466
476
467
477
# SQL panel is still visible
468
478
self .assertTrue (sql_panel .is_displayed ())
479
+
480
+ @override_settings (DEBUG_TOOLBAR_PANELS = ["tests.test_integration.BuggyPanel" ])
481
+ def test_displays_server_error (self ):
482
+ self .selenium .get (self .live_server_url + "/regular/basic/" )
483
+ debug_window = self .selenium .find_element_by_id ("djDebugWindow" )
484
+ self .selenium .find_element_by_class_name ("BuggyPanel" ).click ()
485
+ WebDriverWait (self .selenium , timeout = 3 ).until (EC .visibility_of (debug_window ))
486
+ self .assertEqual (debug_window .text , "»\n 500: Internal Server Error" )
You can’t perform that action at this time.
0 commit comments