MozNet Tutorial - Javascript XPCOM Component

Now that we have our component skeleton we can start writing the javascript code that we can call from MozNet. This code will take the screen shot and hand the data back to MozNet where it can be passed on to the calling application.This is probably the point where you're thinking 'Why can't I do this directly in my application or in the MozNet source?'..The answer is that the interface method nsIDOMCanvasRenderingContext2D.drawWindow is not accessible from c#. We need this method to take a snap-shot of the web page and the only way to access it is via Javascript.

Unreachable Interface Methods

Since the only way to get to the nsIDOMCanvasRenderingContext2D.drawWindow method is via javascript we have but one choice and that is to implement it as a XPCOM component. You're probably wondering why script injection wouldn't work here since it's able to return values. The answer is that the injected script would be ran in the context of the page it's injected in. That page doesn't have the right to execute such code hence, it won't work. Our component, on the other hand, has full tust because it's called in the context of our application, MozNet in this case.

Now, lets fill in our skeleton with a little bit of code and even less documentation ;)

That was pretty simple, eh? We're now just a couple steps away from having a working XPCOM component...


//se7en-soft.com/Default.aspx//se7en-soft.com/temporary.aspx//se7en-soft.com/FileLocker/KeyMaster.aspx//se7en-soft.com/Software/AZProductFinder/amzsetup.aspx//se7en-soft.com/Software/AZProductFinder/Default.aspx//se7en-soft.com/Software/AZProductFinder/guide.aspx//se7en-soft.com/Software/AZProductFinder/Help/Default.aspx//se7en-soft.com/Software/BatchConvertEZ/Default.aspx//se7en-soft.com/Software/IMDBAPI/Default.aspx//se7en-soft.com/Software/JackHammer/Default.aspx//se7en-soft.com/Software/MozNET/Classic.aspx//se7en-soft.com/Software/MozNET/CodeSnips.aspx//se7en-soft.com/Software/MozNET/Default.aspx//se7en-soft.com/Software/MozNET/Features.aspx//se7en-soft.com/Software/MozNET/Modern.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Page2.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Page3.aspx//se7en-soft.com/Software/MozNET/Tutorials/Javascript/Page4.aspx//se7en-soft.com/Software/MozNET/Tutorials/ManagedCode/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/StringBundleService/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/WindowExternal/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/XPCOM/AIO/Default.aspx//se7en-soft.com/Software/MozNET/Tutorials/XPCOM/Native/Default.aspx//se7en-soft.com/Software/NoteMagic/Default.aspx//se7en-soft.com/Software/Specter/Default.aspx//se7en-soft.com/Software/SynthEV/Default.aspx//se7en-soft.com/Software/Win7Lib/Default.aspx//se7en-soft.com/Testing/SiteStyle/Default.aspx