1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/tests/buster/result-view.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,105 @@ 1.4 +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +function onNewResultView(event) 1.10 +{ 1.11 + dump("onNewResultView\n"); 1.12 + const db = runItem.prototype.kDatabase; 1.13 + const kXalan = runItem.prototype.kXalan; 1.14 + var index = view.boxObject.view.selection.currentIndex; 1.15 + var res = view.builder.getResourceAtIndex(index); 1.16 + var name = db.GetTarget(res, krTypeName, true); 1.17 + if (!name) { 1.18 + return false; 1.19 + } 1.20 + var cat = db.GetTarget(res, krTypeCat, true); 1.21 + var path = db.GetTarget(res, krTypePath, true); 1.22 + cat = cat.QueryInterface(nsIRDFLiteral); 1.23 + name = name.QueryInterface(nsIRDFLiteral); 1.24 + path = path.QueryInterface(nsIRDFLiteral); 1.25 + xalan_fl = kXalan.resolve(cat.Value+"/"+path.Value); 1.26 + xalan_ref = kXalan.resolve(cat.Value+"-gold/"+path.Value); 1.27 + var currentResultItem = new Object(); 1.28 + currentResultItem.testpath = xalan_fl; 1.29 + currentResultItem.refpath = xalan_ref; 1.30 + var currentRunItem = itemCache.getItem(res); 1.31 + // XXX todo, keep a list of these windows, so that we can close them. 1.32 + resultWin = window.openDialog('result-view.xul','_blank', 1.33 + 'chrome,resizable,dialog=no', 1.34 + currentResultItem, currentRunItem); 1.35 + return true; 1.36 +} 1.37 + 1.38 +var refInspector; 1.39 +var resInspector; 1.40 + 1.41 +function onResultViewLoad(event) 1.42 +{ 1.43 + dump("onResultViewLoad\n"); 1.44 + aResultItem = window.arguments[0]; 1.45 + aRunItem = window.arguments[1]; 1.46 + var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE; 1.47 + document.getElementById('src').webNavigation.loadURI('view-source:'+ 1.48 + aResultItem.testpath+'.xml', loadFlags, null, null, null); 1.49 + document.getElementById('style').webNavigation.loadURI('view-source:'+ 1.50 + aResultItem.testpath+'.xsl', loadFlags, null, null, null); 1.51 + 1.52 + if (aRunItem && aRunItem.mRefDoc && aRunItem.mResDoc) { 1.53 + document.getElementById("refSourceBox").setAttribute("class", "hidden"); 1.54 + refInspector = new ObjectApp(); 1.55 + refInspector.initialize("refInsp", aRunItem.mRefDoc); 1.56 + resInspector = new ObjectApp(); 1.57 + resInspector.initialize("resInsp", aRunItem.mResDoc); 1.58 + } 1.59 + else { 1.60 + document.getElementById("inspectorBox").setAttribute("class", "hidden"); 1.61 + document.getElementById('ref').webNavigation.loadURI('view-source:'+ 1.62 + aResultItem.refpath+'.out', loadFlags, null, null, null); 1.63 + } 1.64 + return true; 1.65 +} 1.66 + 1.67 +function onResultViewUnload(event) 1.68 +{ 1.69 + dump("onResultUnload\n"); 1.70 +} 1.71 + 1.72 +function ObjectApp() 1.73 +{ 1.74 +} 1.75 + 1.76 +ObjectApp.prototype = 1.77 +{ 1.78 + mDoc: null, 1.79 + mPanelSet: null, 1.80 + 1.81 + initialize: function(aId, aDoc) 1.82 + { 1.83 + this.mDoc = aDoc; 1.84 + this.mPanelSet = document.getElementById(aId).contentDocument.getElementById("bxPanelSet"); 1.85 + this.mPanelSet.addObserver("panelsetready", this, false); 1.86 + this.mPanelSet.initialize(); 1.87 + }, 1.88 + 1.89 + doViewerCommand: function(aCommand) 1.90 + { 1.91 + this.mPanelSet.execCommand(aCommand); 1.92 + }, 1.93 + 1.94 + getViewer: function(aUID) 1.95 + { 1.96 + return this.mPanelSet.registry.getViewerByUID(aUID); 1.97 + }, 1.98 + 1.99 + onEvent: function(aEvent) 1.100 + { 1.101 + switch (aEvent.type) { 1.102 + case "panelsetready": 1.103 + { 1.104 + this.mPanelSet.getPanel(0).subject = this.mDoc; 1.105 + } 1.106 + } 1.107 + } 1.108 +};