summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-31 08:42:21 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-31 08:42:21 +0000
commit13a6abf8b496b855d14b281cd2af1095b179be1c (patch)
tree9df30608a7b79bd7af5f81fc341150e17b63fd0c /webkit/glue
parentef4d0aed4a2702fbd6478b9903f745cc555d930f (diff)
downloadchromium_src-13a6abf8b496b855d14b281cd2af1095b179be1c.zip
chromium_src-13a6abf8b496b855d14b281cd2af1095b179be1c.tar.gz
chromium_src-13a6abf8b496b855d14b281cd2af1095b179be1c.tar.bz2
DevTools: add all scripts from afterCompile events when scripts panel is shown for the first timeBUG=26312
TEST=DevToolsSanityTest.TestScriptsTabIsPopulatedOnInspectedPageRefresh Review URL: http://codereview.chromium.org/341057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js18
-rw-r--r--webkit/glue/devtools/js/tests.js47
2 files changed, 60 insertions, 5 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index 4d89176..41020d6 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -62,10 +62,10 @@ devtools.DebuggerAgent = function() {
this.requestSeqToCallback_ = null;
/**
- * Whether the scripts list has been requested.
+ * Whether the scripts panel has been shown and initialilzed.
* @type {boolean}
*/
- this.scriptsCacheInitialized_ = false;
+ this.scriptsPanelInitialized_ = false;
/**
* Whether the scripts list should be requested next time when context id is
@@ -155,14 +155,22 @@ devtools.DebuggerAgent.prototype.reset = function() {
*/
devtools.DebuggerAgent.prototype.initUI = function() {
// Initialize scripts cache when Scripts panel is shown first time.
- if (this.scriptsCacheInitialized_) {
+ if (this.scriptsPanelInitialized_) {
return;
}
- this.scriptsCacheInitialized_ = true;
+ this.scriptsPanelInitialized_ = true;
if (this.contextId_) {
// We already have context id. This means that we are here from the
// very beginning of the page load cycle and hence will get all scripts
// via after-compile events. No need to request scripts for this session.
+ //
+ // There can be a number of scripts from after-compile events that are
+ // pending addition into the UI.
+ for (var scriptId in this.parsedScripts_) {
+ var script = this.parsedScripts_[scriptId];
+ WebInspector.parsedScriptSource(scriptId, script.getUrl(),
+ undefined /* script source */, script.getLineOffset());
+ }
return;
}
// Script list should be requested only when current context id is known.
@@ -1033,7 +1041,7 @@ devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script, msg) {
var contextType = context.data.type;
this.parsedScripts_[script.id] = new devtools.ScriptInfo(
script.id, script.name, script.lineOffset, contextType);
- if (WebInspector.panels.scripts.element.parentElement) {
+ if (this.scriptsPanelInitialized_) {
// Only report script as parsed after scripts panel has been shown.
WebInspector.parsedScriptSource(
script.id, script.name, script.source, script.lineOffset);
diff --git a/webkit/glue/devtools/js/tests.js b/webkit/glue/devtools/js/tests.js
index 91d8b2f..4b42cc3 100644
--- a/webkit/glue/devtools/js/tests.js
+++ b/webkit/glue/devtools/js/tests.js
@@ -395,6 +395,53 @@ TestSuite.prototype.testShowScriptsTab = function() {
/**
+ * Tests that scripts tab is populated with inspected scripts even if it
+ * hadn't been shown by the moment inspected paged refreshed.
+ * @see http://crbug.com/26312
+ */
+TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh =
+ function() {
+ var test = this;
+ this.assertEquals(WebInspector.panels.elements,
+ WebInspector.currentPanel, 'Elements panel should be current one.');
+
+ this.addSniffer(devtools.DebuggerAgent.prototype, 'reset',
+ waitUntilScriptIsParsed);
+
+ // Reload inspected page. It will reset the debugger agent.
+ test.evaluateInConsole_(
+ 'window.location.reload(true);',
+ function(resultText) {
+ test.assertEquals('undefined', resultText,
+ 'Unexpected result of reload().');
+ });
+
+ function waitUntilScriptIsParsed() {
+ var parsed = devtools.tools.getDebuggerAgent().parsedScripts_;
+ for (var id in parsed) {
+ var url = parsed[id].getUrl();
+ if (url && url.search('debugger_test_page.html$') != -1) {
+ checkScriptsPanel();
+ return;
+ }
+ }
+ test.addSniffer(devtools.DebuggerAgent.prototype, 'addScriptInfo_',
+ waitUntilScriptIsParsed);
+ }
+
+ function checkScriptsPanel() {
+ test.showPanel('scripts');
+ test.assertTrue(test._scriptsAreParsed(['debugger_test_page.html$']),
+ 'Inspected script not found in the scripts list');
+ test.releaseControl();
+ }
+
+ // Wait until all scripts are added to the debugger.
+ this.takeControl();
+};
+
+
+/**
* Tests that scripts list contains content scripts.
*/
TestSuite.prototype.testContentScriptIsPresent = function() {