Skip to content

Commit 127c0a4

Browse files
committed
Merge branch 'devel' of github.com:AngleSharp/AngleSharp.Js into devel
2 parents 105e207 + d81180c commit 127c0a4

File tree

6 files changed

+29
-25
lines changed

6 files changed

+29
-25
lines changed

src/AngleSharp.Js.Tests/ComponentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ComponentTests
1212
private static async Task<String> RunScriptComponent(String script)
1313
{
1414
var service = new JsScriptingService();
15-
var cfg = Configuration.Default.WithXml().With(service);
15+
var cfg = Configuration.Default.WithXml().WithEventLoop().With(service);
1616
var html = String.Concat("<!doctype html><script>", script, "</script>");
1717
var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
1818
var value = service.GetOrCreateJint(document).GetValue("assert");

src/AngleSharp.Js.Tests/FireEventTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class FireEventTests
1313
public async Task InvokeFunctionOnLoadEventShouldFireDelayed()
1414
{
1515
var service = new JsScriptingService();
16-
var cfg = Configuration.Default.With(service);
16+
var cfg = Configuration.Default.With(service).WithEventLoop();
1717
var html = "<!doctype html><div id=result></div><script>document.addEventListener('load', function () { document.querySelector('#result').textContent = 'done'; }, false);</script>";
1818
var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html))
1919
.WhenStable();
@@ -25,7 +25,7 @@ public async Task InvokeFunctionOnLoadEventShouldFireDelayed()
2525
public async Task InvokeFunctionOnCustomEvent()
2626
{
2727
var service = new JsScriptingService();
28-
var cfg = Configuration.Default.With(service);
28+
var cfg = Configuration.Default.With(service).WithEventLoop();
2929
var html = "<!doctype html><div id=result>0</div><script>var i = 0; document.addEventListener('hello', function () { i++; document.querySelector('#result').textContent = i.toString(); }, false);</script>";
3030
var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
3131
var div = document.QuerySelector("#result");
@@ -39,7 +39,7 @@ public async Task InvokeFunctionOnCustomEvent()
3939
public async Task InvokeLoadEventFromJsAndCustomEventFromJsAndCs()
4040
{
4141
var service = new JsScriptingService();
42-
var cfg = Configuration.Default.With(service);
42+
var cfg = Configuration.Default.With(service).WithEventLoop();
4343
var html = @"<!doctype html>
4444
<html>
4545
<body>
@@ -73,7 +73,7 @@ public async Task InvokeLoadEventFromJsAndCustomEventFromJsAndCs()
7373
public async Task AddClickHandlerClassicallyWillExecute()
7474
{
7575
var service = new JsScriptingService();
76-
var cfg = Configuration.Default.With(service);
76+
var cfg = Configuration.Default.With(service).WithEventLoop();
7777
var html = @"<!doctype html>
7878
<html>
7979
<body>
@@ -94,7 +94,7 @@ public async Task AddClickHandlerClassicallyWillExecute()
9494
public async Task AddAndRemoveClickHandlerWontExecute()
9595
{
9696
var service = new JsScriptingService();
97-
var cfg = Configuration.Default.With(service);
97+
var cfg = Configuration.Default.With(service).WithEventLoop();
9898
var html = @"<!doctype html>
9999
<html>
100100
<body>
@@ -116,7 +116,7 @@ public async Task AddAndRemoveClickHandlerWontExecute()
116116
public async Task AddAndInvokeClickHandlerWillChangeCapturedValue()
117117
{
118118
var service = new JsScriptingService();
119-
var cfg = Configuration.Default.With(service);
119+
var cfg = Configuration.Default.With(service).WithEventLoop();
120120
var html = @"<!doctype html>
121121
<html>
122122
<body>
@@ -137,7 +137,7 @@ public async Task AddAndInvokeClickHandlerWillChangeCapturedValue()
137137
public async Task AddAndInvokeClickHandlerWithStringFunctionWontWork()
138138
{
139139
var service = new JsScriptingService();
140-
var cfg = Configuration.Default.With(service);
140+
var cfg = Configuration.Default.With(service).WithEventLoop();
141141
var html = @"<!doctype html>
142142
<html>
143143
<body>
@@ -155,7 +155,7 @@ public async Task AddAndInvokeClickHandlerWithStringFunctionWontWork()
155155
[Test]
156156
public async Task BodyOnloadWorksWhenSetAsAttributeInitially()
157157
{
158-
var cfg = Configuration.Default.WithJs();
158+
var cfg = Configuration.Default.WithJs().WithEventLoop();
159159
var html = @"<!doctype html>
160160
<html>
161161
<body onload='window.foo = 2+3'>
@@ -173,7 +173,7 @@ public async Task BodyOnloadWorksWhenSetAsAttributeInitially()
173173
[Test]
174174
public async Task BodyOnloadWorksWhenSetAsAttributeLater()
175175
{
176-
var cfg = Configuration.Default.WithJs();
176+
var cfg = Configuration.Default.WithJs().WithEventLoop();
177177
var html = @"<!doctype html>
178178
<html>
179179
<body>
@@ -192,7 +192,7 @@ public async Task BodyOnloadWorksWhenSetAsAttributeLater()
192192
public async Task SetTimeoutWithNormalFunction()
193193
{
194194
var service = new JsScriptingService();
195-
var cfg = Configuration.Default.With(service);
195+
var cfg = Configuration.Default.With(service).WithEventLoop();
196196
var html = @"<!doctype html>
197197
<html>
198198
<body>
@@ -214,7 +214,7 @@ public async Task DomContentLoadedEventIsFired_Issue50()
214214
{
215215
//TODO Check this as well on the window level - currently works
216216
//only against document (se AngleSharp#789)
217-
var cfg = Configuration.Default.WithJs();
217+
var cfg = Configuration.Default.WithJs().WithEventLoop();
218218
var html = @"<!doctype html>
219219
<html>
220220
<body>
@@ -236,7 +236,7 @@ public async Task DomContentLoadedEventIsFired_Issue50()
236236
[Test]
237237
public async Task DocumentLoadEventIsFired_Issue42()
238238
{
239-
var cfg = Configuration.Default.WithJs();
239+
var cfg = Configuration.Default.WithJs().WithEventLoop();
240240
var html = @"<!doctype html>
241241
<html>
242242
<body>
@@ -260,7 +260,7 @@ public async Task DocumentLoadEventIsFired_Issue42()
260260
public async Task SetTimeoutWithStringAsFunction()
261261
{
262262
var service = new JsScriptingService();
263-
var cfg = Configuration.Default.With(service);
263+
var cfg = Configuration.Default.With(service).WithEventLoop();
264264
var html = @"<!doctype html>
265265
<html>
266266
<body>

src/AngleSharp.Js.Tests/Helpers.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static class Helpers
1414
public static async Task<String> EvalScriptAsync(this String source)
1515
{
1616
var console = new ConsoleLogger();
17-
var cfg = Configuration.Default.WithJs().WithConsoleLogger(context => console);
17+
var cfg = Configuration.Default.WithJs().WithEventLoop().WithConsoleLogger(context => console);
1818
var html = $"<!doctype html><script>console.log({source})</script>";
1919
await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
2020
return console.Content.ToString().Trim();
@@ -23,6 +23,7 @@ public static async Task<String> EvalScriptAsync(this String source)
2323
internal static IConfiguration GetCssConfig() =>
2424
Configuration.Default
2525
.WithJs()
26+
.WithEventLoop()
2627
.WithCss()
2728
.WithRenderDevice();
2829

src/AngleSharp.Js.Tests/JavascriptErrorTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public class JavascriptErrorTests
1010
public async Task JavascriptErrorInListenerShouldNotThrowJavascriptException()
1111
{
1212
var config = Configuration.Default
13-
.WithJs();
13+
.WithJs()
14+
.WithEventLoop();
1415

1516
var context = BrowsingContext.New(config);
1617

@@ -50,7 +51,8 @@ public async Task CanComputeAndHoistLocalVariablesInForLoop()
5051
return ret;
5152
})('abc').length";
5253
var config = Configuration.Default
53-
.WithJs();
54+
.WithJs()
55+
.WithEventLoop();
5456
var document = await BrowsingContext.New(config).OpenNewAsync();
5557
var result = document.ExecuteScript(source);
5658
Assert.AreEqual(0.0, result);

src/AngleSharp.Js.Tests/JqueryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public async Task JqueryWithAjaxToDelayedResponse()
6565
{
6666
var message = "Hi!";
6767
var req = new DelayedRequester(10, message);
68-
var cfg = Configuration.Default.WithJs().With(req).WithDefaultLoader();
68+
var cfg = Configuration.Default.WithJs().WithEventLoop().With(req).WithDefaultLoader();
6969
var sources = new [] { Constants.Jquery2_1_4, @"
7070
$.ajax('http://example.com/', {
7171
success: function (data, status, xhr) {

src/AngleSharp.Js.Tests/ScriptEvalTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ScriptEvalTests
1414
{
1515
public static async Task<String> EvaluateComplexScriptAsync(params String[] sources)
1616
{
17-
var cfg = Configuration.Default.WithJs();
17+
var cfg = Configuration.Default.WithJs().WithEventLoop();
1818
var scripts = "<script>" + String.Join("</script><script>", sources) + "</script>";
1919
var html = "<!doctype html><div id=result></div>" + scripts;
2020
var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
@@ -79,7 +79,7 @@ public async Task CreateXmlHttpRequestShouldWork()
7979
public async Task PerformXmlHttpRequestSynchronousToDataUrlShouldWork()
8080
{
8181
var req = new DataRequester();
82-
var cfg = Configuration.Default.With(req).WithJs().WithDefaultLoader();
82+
var cfg = Configuration.Default.With(req).WithJs().WithEventLoop().WithDefaultLoader();
8383
var script = "var xhr = new XMLHttpRequest(); xhr.open('GET', 'data:plain/text,Hello World!', false);xhr.send();document.querySelector('#result').textContent = xhr.responseText;";
8484
var html = "<!doctype html><div id=result></div><script>" + script + "</script>";
8585
var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
@@ -92,7 +92,7 @@ public async Task PerformXmlHttpRequestSynchronousToDelayedResponseShouldWork()
9292
{
9393
var message = "Hi!";
9494
var req = new DelayedRequester(10, message);
95-
var cfg = Configuration.Default.WithJs().With(req).WithDefaultLoader();
95+
var cfg = Configuration.Default.WithJs().WithEventLoop().With(req).WithDefaultLoader();
9696
var script = @"
9797
var xhr = new XMLHttpRequest();
9898
xhr.open('GET', 'http://example.com/', false);
@@ -109,7 +109,7 @@ public async Task PerformXmlHttpRequestAsynchronousToDelayedResponseShouldWork()
109109
{
110110
var message = "Hi!";
111111
var req = new DelayedRequester(10, message);
112-
var cfg = Configuration.Default.WithJs().With(req).WithDefaultLoader();
112+
var cfg = Configuration.Default.WithJs().WithEventLoop().With(req).WithDefaultLoader();
113113
var script = @"
114114
var xhr = new XMLHttpRequest();
115115
xhr.open('GET', 'http://example.com/');
@@ -131,9 +131,10 @@ public async Task PerformXmlHttpRequestAsynchronousToDelayedResponseShouldWork()
131131
[Test]
132132
public async Task SetContentOfIFrameElement()
133133
{
134-
var cfg = Configuration.Default.
135-
WithDefaultLoader(new LoaderOptions { IsResourceLoadingEnabled = true }).
136-
WithJs();
134+
var cfg = Configuration.Default
135+
.WithDefaultLoader(new LoaderOptions { IsResourceLoadingEnabled = true })
136+
.WithJs()
137+
.WithEventLoop();
137138
var html = @"<!doctype html><iframe id=myframe srcdoc=''></iframe><script>
138139
var iframe = document.querySelector('#myframe');
139140
var doc = iframe.contentWindow.document;

0 commit comments

Comments
 (0)