Closed Bug 807924 Opened 12 years ago Closed 11 years ago

Trying to inspect objects in Scratchpad sometimes results in type errors

Categories

(DevTools Graveyard :: Scratchpad, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: vporof, Assigned: bbenvie)

References

Details

Attachments

(1 file, 1 obsolete file)

STR:

Write this line in a Scratchpad
>> Object.create(null)
..and Inspect

Error: TypeError: can't convert null to primitive type
Source File: chrome://browser/content/scratchpad.js
Line: 483

..or Display

Error: TypeError: can't convert Object to string
Source File: chrome://browser/content/scratchpad.js
Line: 560

Write this instead:
>> Object.create(null).constructor
or
>> Object.create(null).prototype
and Inspect

Error: Error: First argument must have an objectActor or an object property!
Source File: resource://gre/modules/PropertyPanel.jsm
Line: 114
Priority: -- → P3
Assignee: nobody → bbenvie
I'll fix this in the process of converting the Scratchpad to use VariablesView.
Status: NEW → ASSIGNED
Depends on: 808369
Attached patch WIP1 (obsolete) — Splinter Review
First crack at this. With bug 808369 landing, fixing this just required fixing `Scratchpad.display`. This patch:

* adds a new localization to 'scratchpad.properties' for `stringConversionFailed`
* wraps the conversion to string in `Scratchpad.writeAsComment` in a try-catch
* displays the "Conversion to string failed." error in the catch
* adds a test to confirm this functions as expected
Attached patch WIP2Splinter Review
And of course I forgot to add the new test file.
Attachment #743369 - Attachment is obsolete: true
Attachment #743371 - Flags: review?(rcampbell)
Comment on attachment 743371 [details] [diff] [review]
WIP2

Review of attachment 743371 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/scratchpad/scratchpad.js
@@ +550,5 @@
> +    try {
> +      str = aValue + "";
> +    }
> +    catch (ex) {
> +      str = this.strings.GetStringFromName("stringConversionFailed");

should we return ex.message along with this as well? Though I guess ex.message is likely null. I feel like the exception should return *something*. Maybe preface the str with "Exception: " as we do for other error messages.

::: browser/locales/en-US/chrome/browser/devtools/scratchpad.properties
@@ +89,5 @@
>  fileNoLongerExists.notification=This file no longer exists.
> +
> +# LOCALIZATION NOTE (stringConversionFailed): Happens when a value cannot be
> +# converted to a string for inspection.
> +stringConversionFailed=Cannot convert value to string.
\ No newline at end of file

I think this should be pretty obviously an error.
Attachment #743371 - Flags: review?(rcampbell)
are you still working on this Brandon?
I've been debating how to proceed on this, since I realized the work on bug 825039 kind of subsumes this. I suppose it might be best just to get this finished up and landed and then revisit.
Ok yeah, I'm rolling this into bug 825039.
Depends on: 825039
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: