Closed Bug 270497 Opened 20 years ago Closed 20 years ago

getters/setters for attributes in JS components return NS_ERROR_FAILURE in xpcshell

Categories

(Core :: XPConnect, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 239969

People

(Reporter: vlad, Assigned: dbradley)

Details

Attachments

(1 file)

NS_ERROR_FAILURE is thrown when a pure-JS component implements an attribute
using a getter/setter pair.  Stick the attached sampleComp.js in a components
directory and run xpcshell, then:

var e =
Components.classes["@mozilla.org/test/sample;1"].createInstance(Components.interfaces.nsISample);

e.value

The e.value will throw NS_ERROR_FAILURE.
Note that removing the value getter/setter and changing it to just 'value:
"foo"' causes e.value to work fine.
So, this fails because the script security manager can't find the subject principal:

nsresult
nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction,

    nsCOMPtr<nsIPrincipal> subjectPrincipal;
    if (NS_FAILED(GetSubjectPrincipal(cx, getter_AddRefs(subjectPrincipal))))
        return NS_ERROR_FAILURE;

So it works in chrome or with UniversalXPConnect, but not in xpcshell.

Didn't this used to work?  Did someone dork with the xpcshell security manager?
 (Same behaviour on aviary, so it wouldn't be recent.)
Summary: getters/setters for attributes in JS components return NS_ERROR_FAILURE → getters/setters for attributes in JS components return NS_ERROR_FAILURE in xpcshell
i think i reported this somewhere, there's a proposed fix lying around somewhere
too.

*** This bug has been marked as a duplicate of 239969 ***
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: