Skip to content

Commit 8b29127

Browse files
committed
Merge branch 'graingert-csp'
Closes PR #704. This is the first part of making the toolbar support a content security policy. With this change a user would need to set the script-src directive to contain 'self' 'unsafe-eval' and ajax.googleapis.com, set the img-src directive to contain 'self' and data:. In the future the unsafe-eval value will no longer be needed.
2 parents 4bd0c1c + ed4498c commit 8b29127

File tree

16 files changed

+61
-33
lines changed

16 files changed

+61
-33
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#djDebug {
2+
display:none;
3+
}

debug_toolbar/static/debug_toolbar/css/toolbar.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,3 +646,13 @@
646646
display: none;
647647
}
648648
}
649+
650+
#djDebug .djdt-width-20 {
651+
width: 20%;
652+
}
653+
#djDebug .djdt-width-60 {
654+
width: 60%;
655+
}
656+
#djDebug .djdt-highlighted {
657+
background-color: lightgrey;
658+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var djdt = {jQuery: jQuery};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var _djdt_define_backup = window.define; window.define = undefined;

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,21 @@
285285

286286
return value;
287287
}
288+
},
289+
applyStyle: function(name) {
290+
$('#djDebug [data-' + name + ']').each(function() {
291+
var css = {};
292+
css[name] = $(this).data(name);
293+
$(this).css(css);
294+
});
288295
}
289296
};
290297
$.extend(publicAPI, {
291298
show_toolbar: djdt.show_toolbar,
292299
hide_toolbar: djdt.hide_toolbar,
293300
close: djdt.close,
294-
cookie: djdt.cookie
301+
cookie: djdt.cookie,
302+
applyStyle: djdt.applyStyle
295303
});
296304
$(document).ready(djdt.init);
297305
})(djdt.jQuery, djdt);

debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
subcalls.hide();
1818
}
1919
});
20+
djdt.applyStyle('padding-left');
2021
})(djdt.jQuery);

debug_toolbar/static/debug_toolbar/js/toolbar.sql.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
$(this).parent().find('.djDebugCollapsed').toggle();
55
$(this).parent().find('.djDebugUncollapsed').toggle();
66
});
7+
djdt.applyStyle('background-color');
8+
djdt.applyStyle('left');
9+
djdt.applyStyle('width');
710
})(djdt.jQuery);

debug_toolbar/static/debug_toolbar/js/toolbar.timer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@
2424
if (endStat) {
2525
// Render a start through end bar
2626
$row.html('<td>' + stat.replace('Start', '') + '</td>' +
27-
'<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft(stat) + '%;"><strong style="width:' + getCSSWidth(stat, endStat) + ';">&nbsp;</strong></div></div></td>' +
27+
'<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart"><strong>&nbsp;</strong></div></div></td>' +
2828
'<td>' + (perf.timing[stat] - timingOffset) + ' (+' + (perf.timing[endStat] - perf.timing[stat]) + ')</td>');
29+
$row.find('strong').css({width: getCSSWidth(stat, endStat)});
2930
} else {
3031
// Render a point in time
3132
$row.html('<td>' + stat + '</td>' +
32-
'<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft(stat) + '%;"><strong style="width:2px;">&nbsp;</strong></div></div></td>' +
33+
'<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart"><strong>&nbsp;</strong></div></div></td>' +
3334
'<td>' + (perf.timing[stat] - timingOffset) + '</td>');
35+
$row.find('strong').css({width: 2});
3436
}
37+
$row.find('djDebugLineChart').css({left: getLeft(stat) + '%'});
3538
$('#djDebugBrowserTimingTableBody').append($row);
3639
}
3740

debug_toolbar/templates/debug_toolbar/base.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
{% load i18n %}{% load static from staticfiles %}{% load url from compat %}
2-
<style type="text/css">
3-
@media print { #djDebug {display:none;}}
4-
</style>
2+
<link rel="stylesheet" href="{% static 'debug_toolbar/css/print.css' %}" type="text/css" media="print" />
53
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css" />
64
{% if toolbar.config.JQUERY_URL %}
75
<!-- Prevent our copy of jQuery from registering as an AMD module on sites that use RequireJS. -->
8-
<script>var _djdt_define_backup = window.define; window.define = undefined;</script>
6+
<script src="{% static 'debug_toolbar/js/jquery_pre.js' %}"></script>
97
<script src="{{ toolbar.config.JQUERY_URL }}"></script>
10-
<script>var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;</script>
8+
<script src="{% static 'debug_toolbar/js/jquery_post.js' %}"></script>
119
{% else %}
12-
<script>var djdt = {jQuery: jQuery};</script>
10+
<script src="{% static 'debug_toolbar/js/jquery_existing.js' %}"></script>
1311
{% endif %}
1412
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
15-
<div id="djDebug" style="display:none;" dir="ltr"
13+
<div id="djDebug" hidden="hidden" dir="ltr"
1614
data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"
1715
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>
18-
<div style="display:none;" id="djDebugToolbar">
16+
<div hidden="hidden" id="djDebugToolbar">
1917
<ul id="djDebugPanelList">
2018
{% if toolbar.panels %}
2119
<li><a id="djHideToolBarButton" href="#" title="{% trans "Hide toolbar" %}">{% trans "Hide" %} &#187;</a></li>
@@ -45,7 +43,7 @@
4543
{% endfor %}
4644
</ul>
4745
</div>
48-
<div style="display:none;" id="djDebugToolbarHandle">
46+
<div hidden="hidden" id="djDebugToolbarHandle">
4947
<span title="{% trans "Show toolbar" %}" id="djShowToolBarButton">&#171;</span>
5048
</div>
5149
{% for panel in toolbar.panels %}

0 commit comments

Comments
 (0)