2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / test / xaml / test-downloaderprogress.html
blob746c04ddcbd2b36c8bdc4b4cb5b3e16f8aca58a2
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <title>Test file</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <script src="../js/js/utils.js"></script>
8 <script src="../js/js/testplugin.js"></script>
9 </head>
10 <body>
12 <script type="text/xaml" id="xamlA">
13 <Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
14 Loaded="OnCanvasLoaded"
15 Height="200" Width="200"
16 Background="Blue" />
17 </script>
19 <script type="text/javascript">
20 var last_progress = 0;
22 function OnCanvasLoaded (sender, args)
24 TestLogger.LogDebug ("OnCanvasLoaded");
25 plugin = document.getElementById ("JoltActiveX");
26 dl = plugin.createObject ("Downloader");
28 // Download a file
29 dl.Open ("GET", "../media/video/timecode.mpeg");
30 dl.AddEventListener ("Completed", "OnDownloadCompleted");
31 dl.AddEventListener ("DownloadProgressChanged", "OnDownloadProgressChanged");
32 dl.AddEventListener ("DownloadFailed", "OnDownloadFailed");
33 dl.Send();
36 function OnDownloadFailed (sender, args)
38 Fail ("OnDownloadFailed: " + ErrorEventArgsToOneLineString (args));
41 function OnDownloadProgressChanged (sender, args)
43 TestLogger.LogDebug("OnDownloadProgressChanged: " + sender.DownloadProgress + " (last progress: " + last_progress + ")");
44 // Test that download progress doesn't go down.
45 if (last_progress > sender.DownloadProgress)
46 Fail ("Current progress: " + sender.DownloadProgress + " is less than last progress: " + last_progress);
47 last_progress = sender.DownloadProgress;
50 function OnDownloadCompleted (sender, args)
52 TestLogger.LogDebug ("OnDownloadComplete");
53 if (!ShutdownRequested) {
54 TestLogger.LogResult (1);
55 SignalShutdown ();
59 function OnPluginError (sender, args)
61 Fail ("OnPluginError: " + ErrorEventArgsToOneLineString (args));
64 function Fail (msg)
66 TestLogger.LogError (msg);
67 TestLogger.LogResult (-1)
68 SignalShutdown ();
71 </script>
72 </head>
74 <div>
75 <embed type="application/x-silverlight" width="300" height="300"
76 id="JoltActiveX" Source="#xamlA" OnError="OnPluginError" OnLoad="OnPluginLoaded"
77 style="position:absolute; left:0px; top:0px" background="#CCCCCC">
78 </embed>
79 </div>
81 <!--
82 <embed id="_TestPlugin" width="0" height="0" type="application/x-jolttest"
84 </embed>
85 -->
87 </body>
88 </html>