Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added Weinre remote debugger support

  • Loading branch information...
commit d7d330bf4d44e174d5241d1aca3a02e8be43f1cb 1 parent 59402b9
@sgrebnov authored
View
2  Libraries/Cordova/framework/CordovaView.xaml.cs
@@ -327,7 +327,7 @@ void GapBrowser_LoadCompleted(object sender, System.Windows.Navigation.Navigatio
void GapBrowser_Navigating(object sender, NavigatingEventArgs e)
{
- DebugConsole.WriteLine("GapBrowser_Navigating to :: " + e.Uri.ToString());
+ //DebugConsole.WriteLine("GapBrowser_Navigating to :: " + e.Uri.ToString());
// TODO: tell any running plugins to stop doing what they are doing.
// TODO: check whitelist / blacklist
// NOTE: Navigation can be cancelled by setting : e.Cancel = true;
View
9 Libraries/IE.Debug.Core/DebugTraceListener.cs
@@ -1,13 +1,4 @@
using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
namespace IE.Debug.Core
{
View
4 Libraries/IE.Debug.Core/IE.Debug.Core.csproj
@@ -60,6 +60,10 @@
<Project>{FC6A1A70-892D-46AD-9E4A-9793F72AF780}</Project>
<Name>WP7CordovaClassLib</Name>
</ProjectReference>
+ <ProjectReference Include="..\Support\Support.csproj">
+ <Project>{5F99E641-C43E-49A2-A771-06FC091BE010}</Project>
+ <Name>Support</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
View
7 Libraries/IE.Debug.Core/Scripting.cs
@@ -24,6 +24,13 @@ public static string BuilInjectScript(string link)
link);
}
+ public static string BuilInjectInlineScript(string text)
+ {
+ return String.Format(
+ @"var head = document.getElementsByTagName('head')[0]; var sc1 = document.createElement('script');sc1.innerHTML = '{0}';sc1.type = 'text/javascript'; (head || document.body).appendChild(sc1);",
+ text);
+ }
+
public static string PhoneGapInjectScript
{
get {return BuilInjectScript(PhoneGapLink); }
View
25 Libraries/IE.Debug.Core/WebPageDebugger.cs
@@ -9,6 +9,9 @@
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
+using System.IO.IsolatedStorage;
+using System.IO;
+using Support;
namespace IE.Debug.Core
{
@@ -36,12 +39,34 @@ public static void InstallDebugConsole()
browser.InvokeScript("eval", new string[] { Scripting.PhoneGapInjectScript });
browser.InvokeScript("eval", new string[] { Scripting.BuilInjectScript(@"http://mshare.akvelon.net:8184/cordova-init.js")});
}
+
+ public static void ConnectWeinerDebugger()
+ {
+ ConnectWeiner();
+ }
+
public static void InstallFirebug()
{
browser.InvokeScript("eval", new string[] { Scripting.FirebugInjectScript });
//(@"function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened')();");
}
+ public static void ExecuteCustomScript(string script)
+ {
+ browser.InvokeScript("eval", new string[] { script});
+ }
+
+ public static void ConnectWeiner()
+ {
+
+ browser.InvokeScript("eval", new string[] { @"window.WeinreServerId='wp7'" });
+ browser.InvokeScript("eval", new string[] { @"window.WeinreServerURL='http://debug.shadow.adobe.com:8080'" });
+
+ browser.InvokeScript("eval", new string[] { FileUtils.ReadFileContent("app/www/wp-hacks.js") });
+ browser.InvokeScript("eval", new string[] { FileUtils.ReadFileContent(@"app/www/target-script-min.js") });
+
+ }
+
public static void InjectTestScript()
{
browser.InvokeScript("eval", new string[] { Scripting.BuilInjectScript(Scripting.TestLink) });
View
1  Libraries/Support/Support.csproj
@@ -50,6 +50,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ExceptionHandler.cs" />
+ <Compile Include="FileUtils.cs" />
<Compile Include="Messages.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
View
4 WindowsPhone/Controls/PageHostControl.xaml
@@ -15,8 +15,8 @@
<my:CordovaView HorizontalAlignment="Stretch"
Margin="0,64,0,0"
Name="PGView"
- VerticalAlignment="Stretch" StartPageUri="http://google.com" />
- <TextBox Height="72" HorizontalAlignment="Left" Name="txtUrl" Text="http://google.com" VerticalAlignment="Top" Width="414" Margin="-10,-3,0,0" />
+ VerticalAlignment="Stretch" StartPageUri="http://microsoft.com" />
+ <TextBox Height="72" HorizontalAlignment="Left" Name="txtUrl" Text="http://microsoft.com" VerticalAlignment="Top" Width="414" Margin="-10,-3,0,0" />
<Button Content="go" Height="72" HorizontalAlignment="Left" Margin="384,-1,0,0" Name="btnNavigate" VerticalAlignment="Top" Width="82" Click="btnNavigate_Click" />
</Grid>
View
2  WindowsPhone/CordovaSourceDictionary.xml
@@ -4,5 +4,7 @@
<FilePath Value="www\cordova-1.5.0.js"/>
<FilePath Value="www\index.html"/>
<FilePath Value="www\master.css"/>
+ <FilePath Value="www\target-script-min.js"/>
<FilePath Value="www\test.js"/>
+ <FilePath Value="www\wp-hacks.js"/>
</CordovaSourceDictionary>
View
2  WindowsPhone/IE.Debug.WindowsPhone.csproj
@@ -93,6 +93,7 @@
<Content Include="www\cordova-1.5.0.js" />
<Content Include="www\index.html" />
<Content Include="www\master.css" />
+ <Content Include="www\target-script-min.js" />
<Content Include="www\test.js" />
<Content Include="Images\appbar.debug.rest.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -106,6 +107,7 @@
<Content Include="Images\appbar.plus.rest.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="www\wp-hacks.js" />
<None Include="BuildManifestProcessor.js" />
<None Include="Properties\AppManifest.xml">
<SubType>Designer</SubType>
View
17 WindowsPhone/Views/MainPage.xaml
@@ -15,12 +15,16 @@
shell:SystemTray.IsVisible="True"
xmlns:local="clr-namespace:IE.Debug.WindowsPhone.Controls">
- <Grid x:Name="LayoutRoot" Background="Transparent">
+ <Grid x:Name="LayoutRoot" Margin="0,0,0,0" Height="Auto" Background="Transparent" VerticalAlignment="Top">
<!--Pivot Control-->
<controls:Pivot Title="Windows Phone IE debugger" Name="pivotControl" SelectionChanged="Pivot_SelectionChanged">
-
- <controls:PivotItem Header="main" Tag="pvtMain">
- <local:PageHostControl x:Name="pvtMain"></local:PageHostControl>
+ <!--<controls:Pivot.HeaderTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Title}"/>
+ </DataTemplate>
+ </controls:Pivot.HeaderTemplate>-->
+ <controls:PivotItem Header="main" Height="800" Margin="0,-124,0,0" Tag="pvtMain">
+ <local:PageHostControl x:Name="pvtMain" Width="Auto"></local:PageHostControl>
</controls:PivotItem>
<controls:PivotItem Header="console" Tag="pvtConsole">
@@ -38,7 +42,10 @@
<shell:ApplicationBar x:Key="pvtMainApplicationBar" IsMenuEnabled="True" Opacity="0.5" IsVisible="True">
<shell:ApplicationBarIconButton Click="ActionInstallDebugConsole" IconUri="/Images/appbar.debug.rest.png" Text="Debug"/>
<shell:ApplicationBar.MenuItems>
- <shell:ApplicationBarMenuItem Click="ActionRunFirebug" Text="Run firebug"/>
+ <shell:ApplicationBarMenuItem Click="ActionConnectWeinreDebugger" Text="Weinre debugger"/>
+ <shell:ApplicationBarMenuItem Click="ActionRunFirebug" Text="Run firebug"/>
+ <shell:ApplicationBarMenuItem Click="ActionClearPerfLog" Text="Clear Perf Log"/>
+ <shell:ApplicationBarMenuItem Click="ActionGetPerfLog" Text="Get Perf Log"/>
<!--<shell:ApplicationBarMenuItem Click="ActionRunTestScript" Text="Run test script"/>-->
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
View
17 WindowsPhone/Views/MainPage.xaml.cs
@@ -17,6 +17,7 @@
using IE.Debug.Core;
using IE.Debug.WindowsPhone.Controls;
using Microsoft.Phone.Shell;
+using Microsoft.Phone.Info;
namespace IE.Debug.WindowsPhone.Views
{
@@ -38,6 +39,22 @@ private void ActionRunFirebug(object sender, EventArgs e)
{
WebPageDebugger.InstallFirebug();
}
+
+ private void ActionConnectWeinreDebugger(object sender, EventArgs e)
+ {
+ WebPageDebugger.ConnectWeinerDebugger();
+ }
+
+ private void ActionClearPerfLog(object sender, EventArgs e)
+ {
+ WebPageDebugger.ExecuteCustomScript("window.profiler.reset();");
+ }
+
+ private void ActionGetPerfLog(object sender, EventArgs e)
+ {
+ WebPageDebugger.ExecuteCustomScript("console.log($dumpProfileJSON (window.profiler));");
+ }
+
private void ActionInstallDebugConsole(object sender, EventArgs e)
{
WebPageDebugger.InstallDebugConsole();
Please sign in to comment.
Something went wrong with that request. Please try again.