3

I was wondering if it is possible to create a new XUL component via any available api, such as XPCOM or NPAPI, so we can use it our XUL files.

Let's say I wanted to clone the XULs vbox's components code and add a few modifications to it, so we could use our custom XUL component just like this:

<window>
    <myvbox mycustomarg1="customValue"> Some content... </myvbox>
</window>

I know what XBL is and what is used for and it doesn't fit our need.

Any suggestion of how to achieve that?

Edit:

We need to create a browser component in Firefox as child of another browser object. The problem is some websites detect this child browser as iframe and we want to avoid this.

Thanks.

santiageitorx
  • 103
  • 1
  • 7
  • It isn't clear what you mean by "create a new XUL component" - do you mean defining a new XUL tag with custom behavior? So the same thing as what XBL would do but dynamically? Could you maybe elaborate on why exactly XBL doesn't fit your needs? Note that extending `` or other XUL elements is exactly what XBL is used for. – Wladimir Palant Jun 30 '11 at 11:21
  • For example, we want to be able to get working a xul component that actually doesn't report itself as iframe to websites, so these iframe breaking scripts don't mess up the browsing of certain webs such as hotmail.com or facebook. – santiageitorx Jun 30 '11 at 12:44
  • That's why we need custom xul components and XBL is not a choice – santiageitorx Jun 30 '11 at 12:45
  • That's what `type="content"` is for (https://developer.mozilla.org/en/XUL/Attribute/browser.type). But that won't (cannot) work of course if your XUL document is already in the content area of the browser rather than being opened in a separate window for example. – Wladimir Palant Jun 30 '11 at 12:59
  • You should seriously consider to ask us about your actual problem, not about how to implement the solution you already designed. Because there are strong indications that this solution is wrong in the first place. If you explain the problem we might be able to suggest a better solution. – Wladimir Palant Jun 30 '11 at 13:02
  • Okay, the actual problem is we need to create components whithin an already created object. But we cannot do this for surfing several kind of websites because of their iframe breaking codes. We don't want to try to modify the code of loaded websites as it wouldn't be a good solution, and it wouldn't work for every browsed site. We would like to know if there's any way of getting this done, no matter what technology is used, and how to achieve this goal. Maybe is there any way of isolating this new browser so it doesn't see the parent browser? – santiageitorx Jun 30 '11 at 13:35
  • That's only a problem if the parent browser has `type="content"`. If the parent browser has `type="chrome"` and the child has `type="content"` everything should work just the way you want it. Note that the browser type cannot be changed retroactively, it has to be set before the element is inserted into the document. – Wladimir Palant Jun 30 '11 at 13:41
  • Wladimir, thank you very much for your help. With your suggestion I realized there was no need of using XPCOM ,NPAPI or any other kind of technology which would need to be compiled. Please post this comment as answer so I can mark it as solution. – santiageitorx Jun 30 '11 at 16:02

1 Answers1

2

If the point is preventing a webpage loaded into a frame from messing with your XUL document then you should use <browser type="content"> - this establishes a security boundary between chrome and content which (among other things) prevents the content document from accessing its parent frame. It is important however that your XUL document itself is loaded as chrome and not content (by either being on top level or inside <browser type="chrome">). See https://developer.mozilla.org/en/XUL/Attribute/browser.type for documentation.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126