Skip to content

Commit b681e34

Browse files
committed
Test against #47
1 parent 2552ac0 commit b681e34

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Included new `WithEventLoop` configuration extensions
77
- Added constructors to `window` (#12)
88
- Fixed `btoa` and `atob` missing (#55)
9+
- Included `javascript:` URL handler (#47)
910

1011
# 0.12.1
1112

src/AngleSharp.Js.Tests/InteractionTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace AngleSharp.Js.Tests
22
{
33
using AngleSharp.Dom;
4+
using AngleSharp.Html.Dom;
45
using AngleSharp.Scripting;
56
using Jint.Runtime;
67
using NUnit.Framework;
@@ -110,14 +111,25 @@ public async Task RunScriptSnippetDirectlyGetSimpleValueFromCalculation()
110111
Assert.AreEqual(3.0, result);
111112
}
112113

114+
[Test]
115+
public async Task RunScriptAtPressingLink_Issue47()
116+
{
117+
var html = "<!doctype html><pre id=test></pre><a href=\"javascript:document.querySelector('#test').textContent='success';\">Test</a>";
118+
var config = Configuration.Default.WithJs();
119+
var document = await BrowsingContext.New(config).OpenAsync(m => m.Content(html));
120+
var otherDocument = await document.QuerySelector<IHtmlAnchorElement>("a").NavigateAsync();
121+
Assert.AreEqual(document, otherDocument);
122+
Assert.AreEqual("success", document.QuerySelector("#test").TextContent);
123+
}
124+
113125
[Test]
114126
public async Task SetLocationViaSimpleString_Issue31()
115127
{
116128
var html = "<!doctype html><span id=test>Test</span><script>window.location = '/foo';</script>";
117129
var config = Configuration.Default.WithJs();
118130
var context = BrowsingContext.New(config);
119131
await context.OpenAsync(m => m.Content(html).Address("http://example.com"))
120-
.Then(_ => Assert.AreEqual("foo", context.Active.Location.Href));
132+
.Then(_ => Assert.AreEqual("http://example.com/foo", context.Active.Location.Href));
121133
}
122134

123135
class Person

0 commit comments

Comments
 (0)