Mozilla/mozilla/xpfe/components/sample/resources/nsSampleAppShellComponent.html
law%netscape.com 157bd41438 Revert to proper code to get it working with current JS
git-svn-id: svn://10.0.0.236/trunk@36967 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-26 00:05:17 +00:00

64 lines
2.2 KiB
HTML

<html>
<head>
<script>
var title = "Sample Application Shell Component Test";
var progid = "component://netscape/appshell/component/sample";
var iid = Components.interfaces.nsISampleAppShellComponent;
var observer = {
Observe: function( subject, topic, data ) {
dump( "observe called; subject=[" + subject + "] topic=[" + topic +
"] data=[" + data + "]\n" );
}
}
function RunTest() {
var sampleComponent = Components.classes[progid].getService();
if ( sampleComponent ) {
dump("sampleComponent is " + sampleComponent + "\n" );
sampleComponent = sampleComponent.QueryInterface( iid );
if ( sampleComponent ) {
dump("sampleComponent is " + sampleComponent + "\n" );
sampleComponent.DoDialogTests( window, observer );
} else {
alert( "QueryInterface failed for " + progid + "\n" );
}
} else {
alert( "getService failed for " + progid + "\n" );
}
}
</script>
<title>
<script>document.write(title);</script>
</title>
</head>
<body>
<h1><center>
<script>document.write(title);</script>
</center></h1>
<p/>
This page provides a test of a sample "app shell component."
<p/>
Clicking on the button below will:
<ol>
<p/><li>Execute a JavaScript function that will use XPConnect to dynamically
access that sample component (as a "service" in the nsIServiceManager sense).
Specifically, it will invoke the "DoDialogTests()" member on that service.</li>
<p/><li>That will trigger display of a sequence of dialogs. The first will open
a dialog from C++. You enter some text on that dialog and press a button.</li>
<p/><li>That triggers display of a similar dialog from JavaScript. You enter
some text there and press another button.</li>
<p/><li>Finally, you return here and the results are displayed, demonstrating
that input was passed along to each dialog in turn and that the results
were passed back!</li>
</ol>
<p/>
This sample also demonstrates how to implement an interface in JavaScript and
how to use that interface to communicate with other code using the
nsIObserverService (that's how the results show up back here).
<center>
<button onclick="RunTest()">Click here to test</button>
</center>
<hr/>
</body>
</html>