B2G/gecko/toolkit/content/tests/chrome/RegisterUnregisterChrome.js
// the registrarion when no longer needed.
the registrarion when no longer needed.
the registrarion when no longer needed .
function createManifestTemporarily(tempDir, manifestText)
{
  gPrefs.setBoolPref(XUL_CACHE_PREF, true);
  tempDir.append("temp.manifest");
  let foStream = Cc["@mozilla.org/network/file-output-stream;1"]
                   .createInstance(Ci.nsIFileOutputStream);
  foStream.init(tempDir,
                0x02 | 0x08 | 0x20, 0664, 0); 
  foStream.write(manifestText, manifestText.length);
  foStream.close();
  let tempfile = copyToTemporaryFile(tempDir);
  Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
    autoRegister(tempfile);
  gChromeReg.refreshSkins();
  return function() {
    tempfile.fileSize = 0; 
    gChromeReg.checkForNewChrome();
    gChromeReg.refreshSkins();
    gPrefs.clearUserPref(XUL_CACHE_PREF);
  }
}
function createManifestTemporarily ( tempDir , manifestText ) { gPrefs . setBoolPref ( XUL_CACHE_PREF , true ) ; tempDir . append ( "temp.manifest" ) ; let foStream = Cc [ "@mozilla.org/network/file-output-stream;1" ] . createInstance ( Ci . nsIFileOutputStream ) ; foStream . init ( tempDir , 0x02 | 0x08 | 0x20 , 0664 , 0 ) ; foStream . write ( manifestText , manifestText . length ) ; foStream . close ( ) ; let tempfile = copyToTemporaryFile ( tempDir ) ; Components . manager . QueryInterface ( Ci . nsIComponentRegistrar ) . autoRegister ( tempfile ) ; gChromeReg . refreshSkins ( ) ; return function ( ) { tempfile . fileSize = 0 ; gChromeReg . checkForNewChrome ( ) ; gChromeReg . refreshSkins ( ) ; gPrefs . clearUserPref ( XUL_CACHE_PREF ) ; } }
the registrarion when no longer needed.
the registrarion when no longer needed .
// write, create, truncate // truncate the manifest