Closed Bug 686568 Opened 13 years ago Closed 13 years ago

Allow plugin to set document title

Categories

(Core Graveyard :: Plug-ins, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: shrike, Unassigned)

References

()

Details

Attachments

(1 file)

There is currently no good way for a plug-in to set the document (i.e., top level window) title. Bug 117747, which raised the same issue, was marked as invalid because a work-around exists. But that work-around is a kludge: it is ugly, error-prone (the title must be properly escaped in order to be embedded in a JavaScript string literal; not hard, but not completely trivial, either) and subject to random failure (e.g., by NoScript, which really shouldn't affect a plug-in's ability to set the document title).

A formal proposal for updating the NPAPI to include a sensible way of setting the document title is available at <https://wiki.mozilla.org/NPAPI:DocumentTitle>. This bug can serve as a tracking bug for the implementation of this proposal in Mozilla, should it be adopted.
Alex, this is not actually a bug, it is more of an enhancement request. 
Please mark it accordingly.
Benjamin Smedberg pointed out on the plugin-futures mailing list (message-id <4E70FA2A.1050601@smedbergs.us>) that one can use NPRuntime to accomplish this without evaluating a string at all. His code sketch (with "error and type checking code removed for simplicity") is as follows:

NPObject* window = NULL;
NPN_GetValue(inst, NPNVDOMWindow, &window);

NPVariant documentv;
NPN_GetProperty(inst, window, NPN_GetStringIdentifier("document"), 
&document);

NPObject* document = NPVARIANT_TO_OBJECT(documentv);
NPVariant title;
STRINGZ_TO_NPVARIANT("mynewtitlestring", title);
NPN_SetProperty(inst, document, NPN_GetStringIdentifier("title"), &title);
NPN_ReleaseObject(document);
NPN_ReleaseObject(window);
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: