Closed Bug 480366 Opened 15 years ago Closed 8 years ago

Accessing window.sessionStorage from chrome:// throws an exception ("Operation is not supported" - NS_ERROR_DOM_NOT_SUPPORTED_ERR)

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
minor

Tracking

()

RESOLVED DUPLICATE of bug 600307

People

(Reporter: kael, Assigned: mayhemer)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)
Build Identifier: XULRunner built from a Mozilla Central checkout from Feb. 25 2009

Any attempts to manipulate window.sessionStorage (including typeof and toString) throw exceptions which appear to be the result of XPCOM errors. This works correctly in an equivalent minefield build and in Firefox 3.0.x.

Reproducible: Always

Steps to Reproduce:
1. Load an HTML document in XULRunner that attempts to use typeof, toString, or any other operation on window.sessionStorage (via javascript)
Actual Results:  
An exception is thrown:
exception thrown: [Exception... "Operation is not supported" code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"

Expected Results:  
typeof should have returned a meaningful result, even if it is 'undefined' or 'null'.
toString should have returned a meaningful result.

The test HTML page I created for this functions correctly in minefield and FF3.0.x. This bug isn't about the actual functionality of sessionStorage; we weren't trying to use it, but our actual application was walking over the contents of the window object and calling typeof on them for debugging purposes, which was failing in xulrunner due to this exception.

I will attach my test case (as a working xulrunner application) to this bug. You can run it with 'xulrunner.exe application.ini -console -jsconsole' and you should be able to see the results of the bug at the bottom of the HTML output.

The workaround is to surround any script that walks over the contents of window objects with a try block so that you can catch the exception and handle it, but it feels kind of nasty to have to do that.

Also: I don't know how to get a build identifier out of XULRunner, but this is a build based on mozilla-central as of yesterday (Feb. 25)
Unzip and run this with XULRunner to reproduce the bug. You can open the enclosed test.html file in Firefox to see that it works correctly there.
This is not XULRunner-specific. If you try to access sessionStorage from a chrome:// URL in Firefox, like you probably do in your case, you get the same error.

Related:
bug 371127 - (FIXED) globalStorage from chrome://
bug 495747 - localStorage from chrome://
bug 507361 - localStorage from file://
bug 357323 - sessionStorage from file://

Sigh.

Confirming with Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.3a1pre) Gecko/20090919 Minefield/3.7a1pre
Status: UNCONFIRMED → NEW
Component: General → DOM: Mozilla Extensions
Ever confirmed: true
OS: Windows XP → All
QA Contact: general → general
Hardware: x86 → All
Summary: The window.sessionStorage object throws exceptions when manipulated in XULRunner → Accessing window.sessionStorage from chrome:// throws an exception ("Operation is not supported" - NS_ERROR_DOM_NOT_SUPPORTED_ERR)
Version: unspecified → Trunk
Assignee: nobody → honzab.moz
Flags: blocking1.9.2?
Not blocking 1.9.2 on this.
Flags: blocking1.9.2? → blocking1.9.2-
Will this be fixed sometimes? This bug is still in the current Firefox 8.0 (Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0). Today I found this bug while trying to debug some JavaScript. It keeps crashing with an useless exception for no good reason. I had to add a try-catch with some duplicate code to work around this specific Firefox bug. No other browser does this, as far as I know.

Please edit the title of this report since it's not a XULRunner bug, as said before.
Gonzales: any news?

/be
It appears that this will be fixed by bug 600307.  Using a build with patches from that bug, content.sessionStorage and content.localStorage both return usable storage objects without throwing.
Component: DOM: Mozilla Extensions → DOM
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.