Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Created July 12, 2015 10:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/e921c89cb5694ef299ab to your computer and use it in GitHub Desktop.
Save Noitidart/e921c89cb5694ef299ab to your computer and use it in GitHub Desktop.
_ff-addon-createResourceURI - Createa resource:// URI on the fly.
let res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
res.setSubstitution("rawr", Services.io.newURI('http://www.bing.com/',null,null));
// now try navigating to resource://rawr it will load bing
@Noitidart
Copy link
Author

README

Rev1

  • Works

TODO

  • Try to make resource uri out of a blob like this:
var panelXul = [
  '<?xml version="1.0"?>',
  '<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>',
  '<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidechrome="true" style="background-color: #BC2A4D;" onclick="window.close();"/>'
].join('');

//Cu.importGlobalProperties(['URL']);
var oFileBody = panelXul;
var oBlob = Blob([oFileBody], {
  type: "text/xml"
});
url = URL.createObjectURL(oBlob);

console.log('url:', url);

let res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
res.setSubstitution("rawr", Services.io.newURI('http://www.bing.com',null,null));


var panelWin = Services.ww.openWindow(null, 'resource://rawr', '_blank', 'chrome,alwaysRaised', null, null);
panelWin.addEventListener('load', function() {
  //URL.revokeObjectURL(url);
  panelWin.moveTo(Services.appShell.hiddenDOMWindow.screen.left, Services.appShell.hiddenDOMWindow.screen.top);
  panelWin.resizeTo(Services.appShell.hiddenDOMWindow.screen.width, Services.appShell.hiddenDOMWindow.screen.height);
}, false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment