Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
46284798
Commit
46284798
authored
Apr 08, 2016
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test: allow dataurl sandbox test to run on any URL
parent
8781c770
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
28 deletions
+54
-28
Gruntfile.js
Gruntfile.js
+3
-1
test/renderjs_test.js
test/renderjs_test.js
+51
-27
No files found.
Gruntfile.js
View file @
46284798
...
@@ -89,7 +89,9 @@ module.exports = function (grunt) {
...
@@ -89,7 +89,9 @@ module.exports = function (grunt) {
'
URI
'
,
'
URI
'
,
'
URL
'
,
'
URL
'
,
'
__RenderJSIframeGadget
'
,
'
__RenderJSIframeGadget
'
,
'
__RenderJSEmbeddedGadget
'
'
__RenderJSEmbeddedGadget
'
,
'
FileReader
'
,
'
Blob
'
]
]
}
}
}
}
...
...
test/renderjs_test.js
View file @
46284798
...
@@ -34,6 +34,19 @@
...
@@ -34,6 +34,19 @@
);
);
}
}
function
readBlobAsDataURL
(
blob
)
{
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
fr
.
addEventListener
(
"
load
"
,
function
(
evt
)
{
resolve
(
evt
.
target
.
result
);
});
fr
.
addEventListener
(
"
error
"
,
reject
);
fr
.
readAsDataURL
(
blob
);
},
function
()
{
fr
.
abort
();
});
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// parseGadgetHTMLDocument
// parseGadgetHTMLDocument
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
@@ -3407,34 +3420,37 @@
...
@@ -3407,34 +3420,37 @@
test
(
'
dataurl provide an iframed gadget as callback parameter
'
,
function
()
{
test
(
'
dataurl provide an iframed gadget as callback parameter
'
,
function
()
{
// Check that declare gadget returns the gadget
// Check that declare gadget returns the gadget
var
parent_gadget
=
new
RenderJSGadget
(),
var
parent_gadget
=
new
RenderJSGadget
(),
topURL
=
"
http://example.org/topGadget
"
,
topURL
=
"
http
s
://example.org/topGadget
"
,
parsed
=
URI
.
parse
(
window
.
location
.
href
),
parsed
=
URI
.
parse
(
window
.
location
.
href
),
parent_path
=
URI
.
build
({
protocol
:
parsed
.
protocol
,
parent_path
=
URI
.
build
({
protocol
:
parsed
.
protocol
,
hostname
:
parsed
.
hostname
,
hostname
:
parsed
.
hostname
,
port
:
parsed
.
port
,
port
:
parsed
.
port
,
path
:
parsed
.
path
}).
toString
(),
path
:
parsed
.
path
}).
toString
(),
absolute_path
=
parent_path
+
"
mixed_embedded.html
"
,
// absolute_path = parent_path + "mixed_embedded.html",
data_url
=
"
data:text/html;charset=utf-8;base64,PGh0bWw+PGhlYWQ+PGJhc2
"
+
absolute_path
=
"
https://example.org/mixed_embedded.html
"
,
"
UgaHJlZj0iaHR0cDovLzEyNy4wLjAuMTo5MDAwL3Rlc3QvbWl4ZWRfZW1iZWRkZWQua
"
+
iframe_html_prefix
=
'
<html><head>
'
,
"
HRtbCI+PGJhc2UgaHJlZj0iaHR0cDovLzEyNy4wLjAuMTo5MDAwIj48c2NyaXB0IHNy
"
+
iframe_html_suffix
=
'
<script src="
'
+
"
Yz0iLi4vbm9kZV9tb2R1bGVzL3JzdnAvZGlzdC9yc3ZwLTIuMC40LmpzIiB0eXBlPSJ
"
+
new
URL
(
'
../node_modules/rsvp/dist/rsvp-2.0.4.js
'
,
"
0ZXh0L2phdmFzY3JpcHQiPjwvc2NyaXB0PjxzY3JpcHQgc3JjPSIuLi9kaXN0L3Jlbm
"
+
window
.
location
).
href
+
"
RlcmpzLWxhdGVzdC5qcyIgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij48L3NjcmlwdD48L
"
+
'
"
'
+
"
2hlYWQ+PGJvZHk+PHA+bXkgbWl4ZWQgZm9vPC9wPjwvYm9keT48L2h0bWw+
"
;
// data:text/html;charset=utf-8;base64,
// PGh0bWw+PGJvZHk+PHA+Zm9vPC9wPjwvYm9keT48L2h0bWw+"
this
.
server
.
respondWith
(
"
GET
"
,
"
/test/mixed_embedded.html
"
,
[
200
,
{
"
Content-Type
"
:
"
text/html
"
},
'
<html><head>
'
+
'
<base href="http://127.0.0.1:9000"></base>
'
+
'
<script src="../node_modules/rsvp/dist/rsvp-2.0.4.js"
'
+
'
type="text/javascript"></script>
'
+
'
type="text/javascript"></script>
'
+
'
<script src="../dist/renderjs-latest.js"
'
+
'
<script src="
'
+
new
URL
(
'
../dist/renderjs-latest.js
'
,
window
.
location
).
href
+
'
"
'
+
'
type="text/javascript"></script>
'
+
'
type="text/javascript"></script>
'
+
'
</head><body><p>my mixed foo</p></body></html>
'
]);
'
</head><body><p>my mixed foo</p></body></html>
'
,
iframe_html
=
iframe_html_prefix
+
iframe_html_suffix
,
data_url_html
=
iframe_html_prefix
+
'
<base href="
'
+
absolute_path
+
'
">
'
+
iframe_html_suffix
,
data_url
;
this
.
server
.
respondWith
(
"
GET
"
,
absolute_path
,
[
200
,
{
"
Content-Type
"
:
"
text/html
"
},
iframe_html
]
);
document
.
getElementById
(
"
qunit-fixture
"
).
textContent
=
""
;
document
.
getElementById
(
"
qunit-fixture
"
).
textContent
=
""
;
parent_gadget
.
__path
=
parent_path
;
parent_gadget
.
__path
=
parent_path
;
...
@@ -3444,9 +3460,17 @@
...
@@ -3444,9 +3460,17 @@
};
};
stop
();
stop
();
parent_gadget
.
declareGadget
(
absolute_path
,
{
return
new
RSVP
.
Queue
()
.
then
(
function
()
{
return
readBlobAsDataURL
(
new
Blob
([
data_url_html
],
{
type
:
"
text/html;charset=UTF-8
"
}));
})
.
then
(
function
(
result
)
{
data_url
=
result
;
return
parent_gadget
.
declareGadget
(
absolute_path
,
{
sandbox
:
'
dataurl
'
,
sandbox
:
'
dataurl
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
});
})
})
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
equal
(
new_gadget
.
__path
,
data_url
);
equal
(
new_gadget
.
__path
,
data_url
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment