Closed Bug 239202 Opened 21 years ago Closed 21 years ago

nsIScriptGlobalObjectOwner.getScriptGlobalObject() should be non-scriptable

Categories

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

defect
Not set
trivial

Tracking

()

RESOLVED FIXED

People

(Reporter: jwkbugzilla, Assigned: jwkbugzilla)

Details

Attachments

(5 files, 3 obsolete files)

nsIScriptGlobalObjectOwner.getScriptGlobalObject() returns nsIScriptGlobalObject which isn't accessible from JavaScript so it should have [noscript]. Currently calling this method produces an exception: Error: uncaught exception: [Exception... "Cannot find interface information for parameter arg 0 [nsIScriptGlobalObjectOwner.getScriptGlobalObject]" nsresult: "0x80570006 (NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO)"
Attached patch Patch (obsolete) — Splinter Review
Assignee: general → trev
Status: NEW → ASSIGNED
Attachment #145117 - Flags: review?(bugmail)
Seems like this entire interface could be made non-scriptable. There is no js in the tree that is calling it and trev suggested that the consoleservice could be used which seems like a reasonable idea to me. I definitly don't have any strong oppinions, i just dislike old code that lingers around because 'it might be usefull some day to someone'
Hmm, while we're at it, maybe we want to get rid of the IDL completely and deCOMtaminate this internal interface too? I think I'd prefer that...
trev: any news here? Didn't you have a patch that does what jst suggested in comment 3?
Yes, I have a patch but somehow it makes my build unstable and I didn't have the time to find the reason yet. I'll try to do it the next days.
Wanna post what you have any maybe we can help you sort out what's wrong...?
Attachment #145117 - Flags: review?(bugmail)
I am splitting this patch into three independent parts so I can locate the problem easier. This part removes reportScriptError() from the interface and the only caller now uses nsIConsoleService directly. Tested, works without problems.
Attachment #145117 - Attachment is obsolete: true
Attachment #146181 - Flags: review?(bugmail)
There are some files including nsIScriptGlobalObjectOwner.h without using it - this patch fixes it (everything else are only whitespace changes).
Attachment #146188 - Flags: review?(bugmail)
Comment on attachment 146181 [details] [diff] [review] Part 1 - Kill nsIScriptGlobalObjectOwner.reportScriptError() lol, this is awesome code :) r=me
Attachment #146181 - Flags: review?(bugmail) → review+
Comment on attachment 146181 [details] [diff] [review] Part 1 - Kill nsIScriptGlobalObjectOwner.reportScriptError() Very nice :-) sr=jst
Attachment #146181 - Flags: superreview+
Attachment #146188 - Flags: superreview+
This patch removes the IDL interface (the new file nsIScriptGlobalObjectOwner.h goes into the next attachment, I couldn't find a way to include it into the patch). The new signature for GetScriptGlobalObject is |nsIScriptGlobalObject* GetScriptGlobalObject()| which is the same as in nsIDocument. Maybe nsIDocument should extend nsIScriptGlobalObjectOwner instead of defining the same method again but that's a different issue. This patch seems to work fine, maybe because I applied it to a clean tree now or maybe I fixed the problem when doing some minor changes.
Attachment #146264 - Flags: review?(bugmail)
Comment on attachment 146264 [details] [diff] [review] Part 3 - remove nsIScriptGlobalObjectOwner.idl - In nsXULPrototypeDocument::GetScriptGlobalObject(): + if (!mGlobalObject) { + nsresult rv = NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); + if (NS_FAILED(rv)) + return nsnull; You could just remove this check alltogether, or if you feel more comfortable with checking for an error (if you think NewXULPDGO() might ever return an error, *and* a non-null out param, which would be a bug on its own) you should null out mGlobalObject in case of a failure and fall through to the return at the end. sr=jst
Attachment #146264 - Flags: superreview+
Comment on attachment 146265 [details] New file - /mozilla/dom/public/nsIScriptGlobalObjectOwner.h >/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- This should be C++ now, not IDL. And make the tab width 2. #define NS_ISCRIPTGLOBALOBJECTOWNER_IID \ {0x413e8400, 0xa87f, 0x11d3, \ { 0xaf, 0xc6, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c }} You should generate a new IID for this interface since you're changing the signature. r+sr=jst
Attachment #146265 - Flags: superreview+
Attachment #146265 - Flags: review+
Attachment #146265 - Attachment is obsolete: true
Attachment #146269 - Flags: superreview+
Attachment #146269 - Flags: review+
Comment on attachment 146264 [details] [diff] [review] Part 3 - remove nsIScriptGlobalObjectOwner.idl >+nsIScriptGlobalObject* >+nsXULPrototypeDocument::GetScriptGlobalObject() > { >- nsresult rv = NS_OK; >- if (!mGlobalObject) >- rv = NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); >- *_result = mGlobalObject; >- NS_IF_ADDREF(*_result); >- return rv; >+ if (!mGlobalObject) { >+ nsresult rv = NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); >+ if (NS_FAILED(rv)) >+ return nsnull; >+ } >+ >+ return mGlobalObject; You don't need to do the |NS_FAILED(rv)| check, mGlobalObject has to be null anyway, otherwise the next call to this function would fail. In general, I don't like patches that does sweeping cleanups such as whitespace-cleanups combined with actual functional changes. This makes the patch a lot harder to read and increases to risk of regressions. r=me
Attachment #146264 - Flags: review?(bugmail) → review+
Yes, I've already removed this check after jst commented on it. The current code is: >- nsresult rv = NS_OK; >- if (!mGlobalObject) >- rv = NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); >- *_result = mGlobalObject; >- NS_IF_ADDREF(*_result); >- return rv; >+ if (!mGlobalObject) >+ NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); >+ >+ return mGlobalObject; Do you want me to attach the corrected patch? As to the whitespaces: sorry about this, it's my editor. Maybe I can find a setting to disable conversion of tabs into whitespaces (though it's usually not a big deal, most files contain only a few tabs if any).
Attached patch Patch to be checked in (obsolete) — Splinter Review
This is the patch combining all three parts and jst's correction.
Got rid of bitrot and removed whitespace cleanups, hopefully this time the patch will be checked in.
Attachment #146672 - Attachment is obsolete: true
Checked in.
Checked build 2004071809, nsIScriptGlobalObjectOwner isn't exposed through XPCOM any more. Marking fixed.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: