Allow plugin to set document title

RESOLVED INVALID

Status

()

Core
Plug-ins
--
minor
RESOLVED INVALID
6 years ago
6 years ago

People

(Reporter: Alex Plotnick, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
Created attachment 560045 [details]
Add support for NPPVdocumentTitle variable to NPN_SetValue.

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.
(Reporter)

Updated

6 years ago

Comment 1

6 years ago
Alex, this is not actually a bug, it is more of an enhancement request. 
Please mark it accordingly.
(Reporter)

Comment 2

6 years ago
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
Last Resolved: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.