dom/xslt/tests/buster/result-view.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 function onNewResultView(event)
michael@0 7 {
michael@0 8 dump("onNewResultView\n");
michael@0 9 const db = runItem.prototype.kDatabase;
michael@0 10 const kXalan = runItem.prototype.kXalan;
michael@0 11 var index = view.boxObject.view.selection.currentIndex;
michael@0 12 var res = view.builder.getResourceAtIndex(index);
michael@0 13 var name = db.GetTarget(res, krTypeName, true);
michael@0 14 if (!name) {
michael@0 15 return false;
michael@0 16 }
michael@0 17 var cat = db.GetTarget(res, krTypeCat, true);
michael@0 18 var path = db.GetTarget(res, krTypePath, true);
michael@0 19 cat = cat.QueryInterface(nsIRDFLiteral);
michael@0 20 name = name.QueryInterface(nsIRDFLiteral);
michael@0 21 path = path.QueryInterface(nsIRDFLiteral);
michael@0 22 xalan_fl = kXalan.resolve(cat.Value+"/"+path.Value);
michael@0 23 xalan_ref = kXalan.resolve(cat.Value+"-gold/"+path.Value);
michael@0 24 var currentResultItem = new Object();
michael@0 25 currentResultItem.testpath = xalan_fl;
michael@0 26 currentResultItem.refpath = xalan_ref;
michael@0 27 var currentRunItem = itemCache.getItem(res);
michael@0 28 // XXX todo, keep a list of these windows, so that we can close them.
michael@0 29 resultWin = window.openDialog('result-view.xul','_blank',
michael@0 30 'chrome,resizable,dialog=no',
michael@0 31 currentResultItem, currentRunItem);
michael@0 32 return true;
michael@0 33 }
michael@0 34
michael@0 35 var refInspector;
michael@0 36 var resInspector;
michael@0 37
michael@0 38 function onResultViewLoad(event)
michael@0 39 {
michael@0 40 dump("onResultViewLoad\n");
michael@0 41 aResultItem = window.arguments[0];
michael@0 42 aRunItem = window.arguments[1];
michael@0 43 var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
michael@0 44 document.getElementById('src').webNavigation.loadURI('view-source:'+
michael@0 45 aResultItem.testpath+'.xml', loadFlags, null, null, null);
michael@0 46 document.getElementById('style').webNavigation.loadURI('view-source:'+
michael@0 47 aResultItem.testpath+'.xsl', loadFlags, null, null, null);
michael@0 48
michael@0 49 if (aRunItem && aRunItem.mRefDoc && aRunItem.mResDoc) {
michael@0 50 document.getElementById("refSourceBox").setAttribute("class", "hidden");
michael@0 51 refInspector = new ObjectApp();
michael@0 52 refInspector.initialize("refInsp", aRunItem.mRefDoc);
michael@0 53 resInspector = new ObjectApp();
michael@0 54 resInspector.initialize("resInsp", aRunItem.mResDoc);
michael@0 55 }
michael@0 56 else {
michael@0 57 document.getElementById("inspectorBox").setAttribute("class", "hidden");
michael@0 58 document.getElementById('ref').webNavigation.loadURI('view-source:'+
michael@0 59 aResultItem.refpath+'.out', loadFlags, null, null, null);
michael@0 60 }
michael@0 61 return true;
michael@0 62 }
michael@0 63
michael@0 64 function onResultViewUnload(event)
michael@0 65 {
michael@0 66 dump("onResultUnload\n");
michael@0 67 }
michael@0 68
michael@0 69 function ObjectApp()
michael@0 70 {
michael@0 71 }
michael@0 72
michael@0 73 ObjectApp.prototype =
michael@0 74 {
michael@0 75 mDoc: null,
michael@0 76 mPanelSet: null,
michael@0 77
michael@0 78 initialize: function(aId, aDoc)
michael@0 79 {
michael@0 80 this.mDoc = aDoc;
michael@0 81 this.mPanelSet = document.getElementById(aId).contentDocument.getElementById("bxPanelSet");
michael@0 82 this.mPanelSet.addObserver("panelsetready", this, false);
michael@0 83 this.mPanelSet.initialize();
michael@0 84 },
michael@0 85
michael@0 86 doViewerCommand: function(aCommand)
michael@0 87 {
michael@0 88 this.mPanelSet.execCommand(aCommand);
michael@0 89 },
michael@0 90
michael@0 91 getViewer: function(aUID)
michael@0 92 {
michael@0 93 return this.mPanelSet.registry.getViewerByUID(aUID);
michael@0 94 },
michael@0 95
michael@0 96 onEvent: function(aEvent)
michael@0 97 {
michael@0 98 switch (aEvent.type) {
michael@0 99 case "panelsetready":
michael@0 100 {
michael@0 101 this.mPanelSet.getPanel(0).subject = this.mDoc;
michael@0 102 }
michael@0 103 }
michael@0 104 }
michael@0 105 };

mercurial