Changeset 27892 in webkit
- Timestamp:
- Nov 18, 2007, 3:01:03 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r27886 r27892 1 2007-11-18 Timothy Hatcher <timothy@apple.com> 2 3 Reviewed by Brady. 4 5 Bug 16041: REGRESSION: the Database panel in the Inspector stopped showing errors 6 http://bugs.webkit.org/show_bug.cgi?id=16041 7 8 * page/inspector/DatabasePanel.js: Implement error callbacks to pass to executeSql() 9 and transaction(). Refactored some code for the success and error callbacks to use. 10 1 11 2007-11-18 Alexey Proskuryakov <ap@webkit.org> 2 12 -
trunk/WebCore/page/inspector/DatabasePanel.js
r27883 r27892 188 188 this.resource.database.transaction(function(tx) 189 189 { 190 tx.executeSql(query, [], function(tx, result) { panel.browseQueryFinished(result) }, function(tx, err){ alert(err.message);});191 } );190 tx.executeSql(query, [], function(tx, result) { panel.browseQueryFinished(result) }, function(tx, error) { panel.browseQueryError(error) }); 191 }, function(tx, error) { panel.browseQueryError(error) }); 192 192 }, 193 193 … … 197 197 198 198 var table = this._tableForResult(result); 199 if (table) { 200 var rowCount = table.getElementsByTagName("tr").length; 201 var columnCount = table.getElementsByTagName("tr").item(0).getElementsByTagName("th").length; 202 203 var tr = document.createElement("tr"); 204 tr.className = "database-result-filler-row"; 205 table.appendChild(tr); 206 207 if (!(rowCount % 2)) 208 tr.addStyleClass("alternate"); 209 210 for (var i = 0; i < columnCount; ++i) { 211 var td = document.createElement("td"); 212 tr.appendChild(td); 213 } 214 215 table.addStyleClass("database-browse-table"); 216 this.views.browse.contentElement.appendChild(table); 217 } else { 218 if (!result.errorCode) { 219 var emptyMsgElement = document.createElement("div"); 220 emptyMsgElement.className = "database-table-empty"; 221 emptyMsgElement.textContent = WebInspector.UIString("The “%@”\ntable is empty.", this.currentTable); 222 this.views.browse.contentElement.appendChild(emptyMsgElement); 223 } else { 224 var errorMsgElement = document.createElement("div"); 225 errorMsgElement.className = "database-table-error"; 226 errorMsgElement.textContent = WebInspector.UIString("An error occurred trying to\nread the “%@” table.", this.currentTable); 227 this.views.browse.contentElement.appendChild(errorMsgElement); 228 } 229 } 199 if (!table) { 200 var emptyMsgElement = document.createElement("div"); 201 emptyMsgElement.className = "database-table-empty"; 202 emptyMsgElement.textContent = WebInspector.UIString("The “%@”\ntable is empty.", this.currentTable); 203 this.views.browse.contentElement.appendChild(emptyMsgElement); 204 return; 205 } 206 207 var rowCount = table.getElementsByTagName("tr").length; 208 var columnCount = table.getElementsByTagName("tr").item(0).getElementsByTagName("th").length; 209 210 var tr = document.createElement("tr"); 211 tr.className = "database-result-filler-row"; 212 table.appendChild(tr); 213 214 if (!(rowCount % 2)) 215 tr.addStyleClass("alternate"); 216 217 for (var i = 0; i < columnCount; ++i) { 218 var td = document.createElement("td"); 219 tr.appendChild(td); 220 } 221 222 table.addStyleClass("database-browse-table"); 223 this.views.browse.contentElement.appendChild(table); 224 }, 225 226 browseQueryError: function(error) 227 { 228 this.views.browse.contentElement.removeChildren(); 229 230 var errorMsgElement = document.createElement("div"); 231 errorMsgElement.className = "database-table-error"; 232 errorMsgElement.textContent = WebInspector.UIString("An error occurred trying to\nread the “%@” table.", this.currentTable); 233 this.views.browse.contentElement.appendChild(errorMsgElement); 230 234 }, 231 235 … … 245 249 }, 246 250 247 queryFinished: function(query, result)251 appendQueryResult: function(query, result, resultClassName) 248 252 { 249 253 var commandItem = document.createElement("li"); … … 259 263 commandItem.appendChild(resultDiv); 260 264 261 if (!result.errorCode) { 262 var table = this._tableForResult(result); 263 if (table) 264 resultDiv.appendChild(table); 265 } else { 266 if (this.currentView !== this.views.query) 267 this.currentView = this.views.query; 268 269 if (result.errorCode == 1) { 270 resultDiv.className += " error"; 271 resultDiv.textContent = result.error; 272 } else if (result.errorCode == 2) { 273 resultDiv.className += " error"; 274 resultDiv.textContent = WebInspector.UIString("Database no longer has expected version."); 275 } else { 276 resultDiv.className += " error"; 277 resultDiv.textContent = WebInspector.UIString("An unexpected error %@ occured.", result.errorCode); 278 } 279 } 265 if (resultClassName) 266 resultDiv.addStyleClass(resultClassName); 267 268 if (typeof result === "string" || result instanceof String) 269 resultDiv.textContent = result; 270 else if (result && result.nodeName) 271 resultDiv.appendChild(result); 280 272 281 273 this.views.query.commandListElement.appendChild(commandItem); 282 274 commandItem.scrollIntoView(false); 275 }, 276 277 queryFinished: function(query, result) 278 { 279 this.appendQueryResult(query, this._tableForResult(result)); 280 }, 281 282 queryError: function(query, error) 283 { 284 if (this.currentView !== this.views.query) 285 this.currentView = this.views.query; 286 287 if (error.code == 1) 288 var message = error.message; 289 else if (error.code == 2) 290 var message = WebInspector.UIString("Database no longer has expected version."); 291 else 292 var message = WebInspector.UIString("An unexpected error %@ occured.", error.code); 293 294 this.appendQueryResult(query, message, "error"); 283 295 }, 284 296 … … 295 307 this.resource.database.transaction(function(tx) 296 308 { 297 tx.executeSql(query, [], function(tx, result) { panel.queryFinished(query, result) }, function(tx, err){ alert(err.message);});298 } );309 tx.executeSql(query, [], function(tx, result) { panel.queryFinished(query, result) }, function(tx, error) { panel.queryError(query, error) }); 310 }, function(tx, error) { panel.queryError(query, error) }); 299 311 300 312 this.queryPromptHistory.push(query);
Note:
See TracChangeset
for help on using the changeset viewer.