FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ClearScript/ClearScriptTest/JScriptCoreEngineTest.Windows.cs at master · ddunkin/ClearScript · GitHub
ddunkin
/
ClearScript
Public
forked from
ClearFoundry/ClearScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ClearScript
/
ClearScriptTest
/
JScriptCoreEngineTest.Windows.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (58 loc) · 2.41 KB
Breadcrumbs
ClearScript
/
ClearScriptTest
/
JScriptCoreEngineTest.Windows.cs
Copy path
File metadata and controls
70 lines (58 loc) · 2.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using
System
;
using
System
.
Threading
;
using
System
.
Windows
.
Threading
;
using
Microsoft
.
ClearScript
.
Windows
.
Core
;
using
Microsoft
.
VisualStudio
.
TestTools
.
UnitTesting
;
namespace
Microsoft
.
ClearScript
.
Test
{
public
partial
class
JScriptCoreEngineTest
{
#region test methods
[
TestMethod
,
TestCategory
(
"JScriptCoreEngine"
)
]
public
void
JScriptCoreEngine_AddCOMType_XMLHTTP
(
)
{
var
status
=
0
;
string
data
=
null
;
var
thread
=
new
Thread
(
(
)
=>
{
using
(
var
testEngine
=
new
JScriptEngine
(
Windows
.
WindowsScriptEngineFlags
.
EnableDebugging
|
Windows
.
WindowsScriptEngineFlags
.
EnableStandardsMode
,
NullSyncInvoker
.
Instance
)
)
{
testEngine
.
Script
.
onComplete
=
new
Action
<
int
,
string
>
(
(
xhrStatus
,
xhrData
)
=>
{
status
=
xhrStatus
;
data
=
xhrData
;
Dispatcher
.
ExitAllFrames
(
)
;
}
)
;
Dispatcher
.
CurrentDispatcher
.
BeginInvoke
(
new
Action
(
(
)
=>
{
// ReSharper disable AccessToDisposedClosure
testEngine
.
AddCOMType
(
"XMLHttpRequest"
,
"MSXML2.XMLHTTP"
)
;
testEngine
.
Execute
(
@"
xhr = new XMLHttpRequest();
xhr.open('POST', 'http://httpbin.org/post', true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
onComplete(xhr.status, JSON.parse(xhr.responseText).data);
}
};
xhr.send('Hello, world!');
"
)
;
// ReSharper restore AccessToDisposedClosure
}
)
)
;
Dispatcher
.
Run
(
)
;
}
}
)
;
thread
.
SetApartmentState
(
ApartmentState
.
STA
)
;
thread
.
Start
(
)
;
if
(
!
thread
.
Join
(
TimeSpan
.
FromSeconds
(
5
)
)
)
{
Assert
.
Inconclusive
(
"The Httpbin service request timed out"
)
;
}
Assert
.
AreEqual
(
200
,
status
)
;
Assert
.
AreEqual
(
"Hello, world!"
,
data
)
;
}
#endregion
}
}
Back
|
FazBrowse Home
|
New Git URL