Web Inspector: ResourceContentView.js incorrectly contains call to WebInspector.UIStr...
authorjonowells@apple.com <jonowells@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 00:44:45 +0000 (00:44 +0000)
committerjonowells@apple.com <jonowells@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 00:44:45 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140268

Reviewed by Timothy Hatcher.

UIString no longer incorrectly used around variables. Drive-by fixes to prototype inheritance style.
Use of Promises corrected such that requesting content for a resource resolves rather than rejects if
a resource can't be found or has another error that isn't a web inspector error.

* Localizations/en.lproj/localizedStrings.js: Updated.
* UserInterface/Models/Resource.js: Change reject to resolve.
* UserInterface/Models/Script.js:
(WebInspector.Script.prototype.requestContentFromBackend): Proper use of Error object.
* UserInterface/Models/SourceCode.js: Use correct inheritance style.
* UserInterface/Views/ResourceContentView.js:
(WebInspector.ResourceContentView.prototype._contentAvailable): Handle error now that promise resolves.
(WebInspector.ResourceContentView.prototype._contentError): Remove incorrect use of UIString.
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._contentAvailable): Handle error now that promise resolves.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178970 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Models/Script.js
Source/WebInspectorUI/UserInterface/Models/SourceCode.js
Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js

index 56dac51..d48e44a 100644 (file)
@@ -1,3 +1,25 @@
+2015-01-22  Jonathan Wells  <jonowells@apple.com>
+
+        Web Inspector: ResourceContentView.js incorrectly contains call to WebInspector.UIString with a variable parameter
+        https://bugs.webkit.org/show_bug.cgi?id=140268
+
+        Reviewed by Timothy Hatcher.
+
+        UIString no longer incorrectly used around variables. Drive-by fixes to prototype inheritance style.
+        Use of Promises corrected such that requesting content for a resource resolves rather than rejects if
+        a resource can't be found or has another error that isn't a web inspector error.
+
+        * Localizations/en.lproj/localizedStrings.js: Updated.
+        * UserInterface/Models/Resource.js: Change reject to resolve.
+        * UserInterface/Models/Script.js:
+        (WebInspector.Script.prototype.requestContentFromBackend): Proper use of Error object.
+        * UserInterface/Models/SourceCode.js: Use correct inheritance style.
+        * UserInterface/Views/ResourceContentView.js:
+        (WebInspector.ResourceContentView.prototype._contentAvailable): Handle error now that promise resolves.
+        (WebInspector.ResourceContentView.prototype._contentError): Remove incorrect use of UIString.
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype._contentAvailable): Handle error now that promise resolves.
+
 2015-01-22  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Expected gutter highlight when selecting console input line, just like output line
index dc4820b..7ce53ae 100644 (file)
Binary files a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js and b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js differ
index 4ca4d6a..f68627e 100644 (file)
@@ -186,6 +186,7 @@ WebInspector.Resource.displayNameForType = function(type, plural)
 
 WebInspector.Resource.prototype = {
     constructor: WebInspector.Resource,
+    __proto__: WebInspector.SourceCode.prototype,
 
     // Public
 
@@ -679,7 +680,7 @@ WebInspector.Resource.prototype = {
             return WebInspector.SourceCode.prototype.requestContent.call(this);
 
         if (this._failed)
-            return Promise.reject(new Error("An error occurred trying to load the resource."));
+            return Promise.resolve({ error: WebInspector.UIString("An error occurred trying to load the resource.") });
 
         if (!this._finishThenRequestContentPromise) {
             var listener = new WebInspector.EventListener(this, true);
@@ -714,5 +715,3 @@ WebInspector.Resource.prototype = {
         cookie[WebInspector.Resource.MainResourceCookieKey] = this.isMainResource();
     }
 };
-
-WebInspector.Resource.prototype.__proto__ = WebInspector.SourceCode.prototype;
index 8340c35..88470c4 100644 (file)
@@ -58,6 +58,7 @@ WebInspector.Script._nextUniqueDisplayNameNumber = 1;
 
 WebInspector.Script.prototype = {
     constructor: WebInspector.Script,
+    __proto__: WebInspector.SourceCode.prototype,
 
     // Public
 
@@ -110,12 +111,12 @@ WebInspector.Script.prototype = {
         return this._scriptSyntaxTree;
     },
 
-    requestContentFromBackend: function(callback)
+    requestContentFromBackend: function()
     {
         if (!this._id) {
             // There is no identifier to request content with. Return false to cause the
             // pending callbacks to get null content.
-            return Promise.reject({ message: "There is no identifier to request content with." });
+            return Promise.reject(new Error("There is no identifier to request content with."));
         }
 
         return DebuggerAgent.getScriptSource.promise(this._id);
@@ -212,5 +213,3 @@ WebInspector.Script.prototype = {
         this._scriptSyntaxTree = new WebInspector.ScriptSyntaxTree(sourceText, this);
     }
 };
-
-WebInspector.Script.prototype.__proto__ = WebInspector.SourceCode.prototype;
index a70719d..c166239 100644 (file)
@@ -47,6 +47,7 @@ WebInspector.SourceCode.Event = {
 
 WebInspector.SourceCode.prototype = {
     constructor: WebInspector.SourceCode,
+    __proto__: WebInspector.Object.prototype,
 
     // Public
 
@@ -206,5 +207,3 @@ WebInspector.SourceCode.prototype = {
         });
     }
 };
-
-WebInspector.SourceCode.prototype.__proto__ = WebInspector.Object.prototype;
index 150bc59..58f7414 100644 (file)
@@ -58,6 +58,7 @@ WebInspector.ResourceContentView.StyleClassName = "resource";
 
 WebInspector.ResourceContentView.prototype = {
     constructor: WebInspector.ResourceContentView,
+    __proto__: WebInspector.ContentView.prototype,
 
     // Public
 
@@ -88,6 +89,11 @@ WebInspector.ResourceContentView.prototype = {
 
     _contentAvailable: function(parameters)
     {
+        if (parameters.error) {
+            this._contentError({ message: parameters.error });
+            return;
+        }
+
         // Content is ready to show, call the public method now.
         this.contentAvailable(parameters.content, parameters.base64Encoded);
     },
@@ -99,7 +105,7 @@ WebInspector.ResourceContentView.prototype = {
             return;
 
         this.element.removeChildren();
-        this.element.appendChild(WebInspector.createMessageTextView(WebInspector.UIString(error.message), true));
+        this.element.appendChild(WebInspector.createMessageTextView(error.message, true));
     },
 
     _issueWasAdded: function(event)
@@ -120,5 +126,3 @@ WebInspector.ResourceContentView.prototype = {
         WebInspector.handlePossibleLinkClick(event, this.resource.parentFrame);
     }
 };
-
-WebInspector.ResourceContentView.prototype.__proto__ = WebInspector.ContentView.prototype;
index 9268d5b..6965f8f 100644 (file)
@@ -510,6 +510,10 @@ WebInspector.SourceCodeTextEditor.prototype = {
 
     _contentAvailable: function(parameters)
     {
+        // Return if resource is not available.
+        if (parameters.error)
+            return;
+
         var sourceCode = parameters.sourceCode;
         var content = parameters.content;
         var base64Encoded = parameters.base64Encoded;