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
0098821d
Commit
0098821d
authored
Dec 04, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Iframe: handle not transferrable object through postMessage
parent
b715d066
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
15 deletions
+68
-15
lib/jschannel/jschannel.js
lib/jschannel/jschannel.js
+12
-8
renderjs.js
renderjs.js
+14
-6
test/embedded.js
test/embedded.js
+11
-0
test/renderjs_test.js
test/renderjs_test.js
+31
-1
No files found.
lib/jschannel/jschannel.js
View file @
0098821d
...
@@ -300,24 +300,28 @@
...
@@ -300,24 +300,28 @@
postMessage
({
id
:
id
,
callback
:
cbName
,
params
:
v
});
postMessage
({
id
:
id
,
callback
:
cbName
,
params
:
v
});
},
},
error
:
function
(
error
,
message
)
{
error
:
function
(
error
,
message
)
{
completed
=
true
;
// verify in table
// verify in table
if
(
!
inTbl
[
id
])
throw
"
error called for nonexistent message:
"
+
id
;
if
(
!
inTbl
[
id
])
throw
"
error called for nonexistent message:
"
+
id
;
// remove transaction from table
delete
inTbl
[
id
];
// send error
// send error
postMessage
({
id
:
id
,
error
:
error
,
message
:
message
});
postMessage
({
id
:
id
,
error
:
error
,
message
:
message
});
completed
=
true
;
// remove transaction from table
delete
inTbl
[
id
];
},
},
complete
:
function
(
v
)
{
complete
:
function
(
v
)
{
completed
=
true
;
// verify in table
// verify in table
if
(
!
inTbl
[
id
])
throw
"
complete called for nonexistent message:
"
+
id
;
if
(
!
inTbl
[
id
])
throw
"
complete called for nonexistent message:
"
+
id
;
// remove transaction from table
delete
inTbl
[
id
];
// send complete
// send complete
postMessage
({
id
:
id
,
result
:
v
});
postMessage
({
id
:
id
,
result
:
v
});
completed
=
true
;
// remove transaction from table
delete
inTbl
[
id
];
},
},
delayReturn
:
function
(
delay
)
{
delayReturn
:
function
(
delay
)
{
if
(
typeof
delay
===
'
boolean
'
)
{
if
(
typeof
delay
===
'
boolean
'
)
{
...
...
renderjs.js
View file @
0098821d
...
@@ -2065,10 +2065,11 @@
...
@@ -2065,10 +2065,11 @@
local_transaction_dict
[
transaction_id
]
=
local_transaction_dict
[
transaction_id
]
=
root_gadget
[
v
[
0
]].
apply
(
root_gadget
,
v
[
1
])
root_gadget
[
v
[
0
]].
apply
(
root_gadget
,
v
[
1
])
.
push
(
function
handleMethodCallSuccess
()
{
.
push
(
function
handleMethodCallSuccess
()
{
trans
.
complete
.
apply
(
trans
,
arguments
);
// drop the promise reference, to allow garbage collection
// drop the promise reference, to allow garbage collection
delete
local_transaction_dict
[
transaction_id
];
delete
local_transaction_dict
[
transaction_id
];
trans
.
complete
.
apply
(
trans
,
arguments
);
})
}
,
function
handleMethodCallError
(
e
)
{
.
push
(
undefined
,
function
handleMethodCallError
(
e
)
{
var
error_type
=
convertObjectToErrorType
(
e
),
var
error_type
=
convertObjectToErrorType
(
e
),
message
;
message
;
if
(
e
instanceof
Error
)
{
if
(
e
instanceof
Error
)
{
...
@@ -2080,12 +2081,19 @@
...
@@ -2080,12 +2081,19 @@
}
else
{
}
else
{
message
=
e
;
message
=
e
;
}
}
// drop the promise reference, to allow garbage collection
try
{
delete
local_transaction_dict
[
transaction_id
];
trans
.
error
({
trans
.
error
({
type
:
error_type
,
type
:
error_type
,
msg
:
message
msg
:
message
});
});
}
catch
(
new_error
)
{
trans
.
error
({
type
:
convertObjectToErrorType
(
new_error
),
msg
:
new_error
.
toString
()
});
}
// drop the promise reference, to allow garbage collection
delete
local_transaction_dict
[
transaction_id
];
});
});
trans
.
delayReturn
(
true
);
trans
.
delayReturn
(
true
);
});
});
...
...
test/embedded.js
View file @
0098821d
...
@@ -168,6 +168,17 @@
...
@@ -168,6 +168,17 @@
"
isAcquiredMethodCancelCalled
"
)
"
isAcquiredMethodCancelCalled
"
)
.
declareMethod
(
'
wasAcquiredMethodCancelCalledFromParent
'
,
function
()
{
.
declareMethod
(
'
wasAcquiredMethodCancelCalledFromParent
'
,
function
()
{
return
this
.
isAcquiredMethodCancelCalled
();
return
this
.
isAcquiredMethodCancelCalled
();
})
.
declareMethod
(
'
returnNotTransferrable
'
,
function
()
{
var
a
=
{};
a
.
a
=
a
;
return
a
;
})
.
declareMethod
(
'
throwNotTransferrable
'
,
function
()
{
var
a
=
{};
a
.
a
=
a
;
throw
a
;
});
});
}(
window
,
rJS
,
RSVP
));
}(
window
,
rJS
,
RSVP
));
test/renderjs_test.js
View file @
0098821d
...
@@ -5872,7 +5872,7 @@
...
@@ -5872,7 +5872,7 @@
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
4
2
);
expect
(
4
6
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
),
element
:
document
.
getElementById
(
'
qunit-fixture
'
),
...
@@ -6148,6 +6148,36 @@
...
@@ -6148,6 +6148,36 @@
error
.
toString
(),
error
.
toString
(),
"
IframeSerializationError: String Error
"
"
IframeSerializationError: String Error
"
);
);
})
// returning not transferrable object fails
.
push
(
function
()
{
return
new_gadget
.
returnNotTransferrable
();
})
.
push
(
undefined
,
function
(
error
)
{
ok
(
error
instanceof
renderJS
.
IframeSerializationError
,
JSON
.
stringify
(
error
)
);
equal
(
error
.
toString
(),
"
IframeSerializationError: TypeError: cyclic object value
"
);
})
// throw not transferrable object fails
.
push
(
function
()
{
return
new_gadget
.
throwNotTransferrable
();
})
.
push
(
undefined
,
function
(
error
)
{
ok
(
error
instanceof
renderJS
.
IframeSerializationError
,
JSON
.
stringify
(
error
)
);
equal
(
error
.
toString
(),
"
IframeSerializationError: TypeError: cyclic object value
"
);
});
});
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
...
...
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