views:

32

answers:

1

I want to write some tests that involve communicating from javascript from Silverlight and I want to know if it is possible to inject javascript at runtime?

So in my test project I have the following method in the app.xaml file and I want to be able to dynamically include\insert some javascript.

private void Application_Startup(object sender, StartupEventArgs e)
{
     RootVisual = UnitTestSystem.CreateTestPage();
}

Cheers

AWC

+1  A: 

Do some research into the.

HtmlPage.Window.Eval(...)

http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlwindow.eval(VS.95).aspx

Also - I wouldn't recommend setting up the javscript with in your Application_Startup (of course I don't know your requirements)...

I would recommend placing it with in your test specific code - or test setup and when done with the test - cleaning up any javascript code you inject.

Hope this helps.

Jason Jarrett