Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 995a05a

Browse files
committed
tests and comment
1 parent f90b652 commit 995a05a

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

lib/js/tests/Webapi/Webapi__Dom/Webapi__Dom__BeforeUnloadEvent__test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ $$event.stopPropagation();
3535

3636
$$event.returnValue;
3737

38+
$$event.returnValue = "Test";
39+
3840
exports.$$event = $$event;
3941
/* event Not a pure module */

lib/js/tests/Webapi/Webapi__Dom/Webapi__Dom__Window__test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ window.scrollBy(10.0, -10.0);
146146

147147
window.scrollTo(120.5, 300.3);
148148

149+
window.addEventListener("beforeunload", (function (param) {
150+
return /* () */0;
151+
}));
152+
153+
window.removeEventListener("beforeunload", (function (param) {
154+
return /* () */0;
155+
}));
156+
149157
window.stop();
150158

151159
window.onload = (function (param) {

src/Webapi/Webapi__Dom/Webapi__Dom__BeforeUnloadEvent.re

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ include Webapi__Dom__Event.Impl({ type nonrec t = t; });
66
[@bs.new] external makeWithOptions : (string, Js.t({..})) => t = "BeforeUnloadEvent";
77

88
[@bs.get] external returnValue : t => string = "";
9+
/**
10+
* returnValue cannot be unset because BS cannot (afaik) bind `delete e['returnValue'];`
11+
* Setting the value to undefined does not either.
12+
*/
913
[@bs.set] external setReturnValue: (t, string) => unit = "returnValue";

tests/Webapi/Webapi__Dom/Webapi__Dom__BeforeUnloadEvent__test.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ stopPropagation(event);
2121

2222
/* BeforeUnloadEvent */
2323
let _ = returnValue(event);
24+
setReturnValue(event, "Test");

tests/Webapi/Webapi__Dom/Webapi__Dom__Window__test.re

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,7 @@ let _ = Window.resizeTo(120, 300, window);
7070
let _ = Window.scroll(0.0, 0.0, window);
7171
let _ = Window.scrollBy(10.0, (-10.0), window);
7272
let _ = Window.scrollTo(120.5, 300.3, window);
73+
Window.addBeforeUnloadEventListener((_: BeforeUnloadEvent.t) => (), window);
74+
Window.removeBeforeUnloadEventListener((_: BeforeUnloadEvent.t) => (), window);
7375
Window.stop(window);
7476
Window.setOnLoad(window, () => print_endline("load"));

0 commit comments

Comments
 (0)