Skip to content

Commit

Permalink
Enable constructing Page{Reveal|Swap}Event
Browse files Browse the repository at this point in the history
As per spec
https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-pagerevealevent-interface
https://html.spec.whatwg.org/multipage/nav-history-apis.html#pageswapevent

Bug: 354588516
Change-Id: I108e5a16af2fc4da3d5030589c820c9fd309bf65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5724461
Reviewed-by: Khushal Sagar <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1331321}
  • Loading branch information
noamr authored and chromium-wpt-export-bot committed Jul 22, 2024
1 parent cbf74ff commit 95d7dbe
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
42 changes: 42 additions & 0 deletions css/css-view-transitions/navigation/pagereveal-ctor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>
<title>ßPageRevelEvent constructor</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-pagerevealevent-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var e = new PageRevealEvent("something");
assert_true(e instanceof PageRevealEvent);
assert_equals(e.type, "something");
assert_equals(e.viewTransition, null);
}, "Constructing pagereveal event");

test(function() {
var e = new PageRevealEvent("pagereveal");
assert_true(e instanceof PageRevealEvent);
assert_equals(e.type, "pagereveal");
assert_equals(e.viewTransition, null);
}, "Constructing pagereveal event with a custom name");

test(function() {
var e = new PageRevealEvent("pagereveal", {});
assert_true(e instanceof PageRevealEvent);
assert_equals(e.type, "pagereveal");
assert_equals(e.viewTransition, null);
}, "Constructing pagereveal event with empty dictionary");

test(function() {
var e = new PageRevealEvent("pagereveal", {viewTransition: null});
assert_true(e instanceof PageRevealEvent);
assert_equals(e.type, "pagereveal");
assert_equals(e.viewTransition, null);
}, "Constructing pagereveal event with a null viewTransition");
test(function() {
const viewTransition = document.startViewTransition();
var e = new PageRevealEvent("pagereveal", {viewTransition});
assert_true(e instanceof PageRevealEvent);
assert_equals(e.type, "pagereveal");
assert_equals(e.viewTransition, viewTransition);
}, "Constructing pagereveal event with a viewTransition");
</script>
54 changes: 54 additions & 0 deletions css/css-view-transitions/navigation/pageswap-ctor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!doctype html>
<title> PageSwapEvent constructor</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-pageswapevent-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var e = new PageSwapEvent("something");
assert_true(e instanceof PageSwapEvent);
assert_equals(e.type, "something");
assert_equals(e.viewTransition, null);
assert_equals(e.activation, null);
}, "Constructing pageswap event");

test(function() {
var e = new PageSwapEvent("pageswap");
assert_true(e instanceof PageSwapEvent);
assert_equals(e.type, "pageswap");
assert_equals(e.viewTransition, null);
assert_equals(e.activation, null);
}, "Constructing pageswap event with a custom name");

test(function() {
var e = new PageSwapEvent("pageswap", {});
assert_true(e instanceof PageSwapEvent);
assert_equals(e.type, "pageswap");
assert_equals(e.viewTransition, null);
assert_equals(e.activation, null);
}, "Constructing pageswap event with empty dictionary");

test(function() {
var e = new PageSwapEvent("pageswap", {viewTransition: null});
assert_true(e instanceof PageSwapEvent);
assert_equals(e.type, "pageswap");
assert_equals(e.viewTransition, null);
assert_equals(e.activation, null);
}, "Constructing pageswap event with a null viewTransition");
test(function() {
const viewTransition = document.startViewTransition();
var e = new PageSwapEvent("pageswap", {viewTransition});
assert_true(e instanceof PageSwapEvent);
assert_equals(e.type, "pageswap");
assert_equals(e.viewTransition, viewTransition);
}, "Constructing pageswap event with a viewTransition");
test(function() {
const viewTransition = document.startViewTransition();
var e = new PageSwapEvent("pageswap", {viewTransition, activation: navigation.activation});
assert_true(e instanceof PageSwapEvent);
assert_equals(e.type, "pageswap");
assert_equals(e.viewTransition, viewTransition);
assert_equals(e.activation, navigation.activation);
}, "Constructing pageswap event with a viewTransition and activation");
</script>

0 comments on commit 95d7dbe

Please sign in to comment.