-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This object includes a url, a sameDocument boolean, and a getState() function that returns the state object that will be restored when the navigation completes (if this is a back/forward navigation to a history entry that had appHistory state). Bug: 1183545 Change-Id: I049f522108f8cc8bb69e7e3c5b6c9edfb40abcef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2960662 Reviewed-by: Domenic Denicola <domenic@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/master@{#892784}
- Loading branch information
1 parent
de608f2
commit 1515c99
Showing
35 changed files
with
174 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
third_party/blink/renderer/core/app_history/app_history_destination.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_APP_HISTORY_APP_HISTORY_DESTINATION_H_ | ||
#define THIRD_PARTY_BLINK_RENDERER_CORE_APP_HISTORY_APP_HISTORY_DESTINATION_H_ | ||
|
||
#include "third_party/blink/renderer/bindings/core/v8/script_value.h" | ||
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h" | ||
#include "third_party/blink/renderer/core/core_export.h" | ||
#include "third_party/blink/renderer/platform/bindings/script_state.h" | ||
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" | ||
#include "third_party/blink/renderer/platform/heap/heap_allocator.h" | ||
#include "third_party/blink/renderer/platform/heap/member.h" | ||
#include "third_party/blink/renderer/platform/weborigin/kurl.h" | ||
|
||
namespace blink { | ||
|
||
class CORE_EXPORT AppHistoryDestination final : public ScriptWrappable { | ||
DEFINE_WRAPPERTYPEINFO(); | ||
|
||
public: | ||
AppHistoryDestination(const KURL& url, | ||
bool same_document, | ||
SerializedScriptValue* state) | ||
: url_(url), same_document_(same_document), state_(state) {} | ||
~AppHistoryDestination() final = default; | ||
|
||
const KURL& url() const { return url_; } | ||
bool sameDocument() const { return same_document_; } | ||
ScriptValue getState(ScriptState* script_state) { | ||
v8::Isolate* isolate = script_state->GetIsolate(); | ||
return state_ ? ScriptValue(isolate, state_->Deserialize(isolate)) | ||
: ScriptValue(); | ||
} | ||
|
||
private: | ||
KURL url_; | ||
bool same_document_; | ||
scoped_refptr<SerializedScriptValue> state_; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_APP_HISTORY_APP_HISTORY_DESTINATION_H_ |
13 changes: 13 additions & 0 deletions
13
third_party/blink/renderer/core/app_history/app_history_destination.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// https://github.com/WICG/app-history/ | ||
[ | ||
Exposed=Window, | ||
RuntimeEnabled=AppHistory | ||
] interface AppHistoryDestination { | ||
readonly attribute USVString url; | ||
readonly attribute boolean sameDocument; | ||
[CallWith=ScriptState] any getState(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...s/wpt_internal/app-history/navigate-event/navigate-destination-getState-back-forward.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
async_test(t => { | ||
// step_timeout because blink doesn't create history entries if onload has not | ||
// yet completed. | ||
window.onload = () => t.step_timeout(t.step_func_done(() => { | ||
let navState = { statevar: "state" }; | ||
appHistory.navigate("#foo", { replace: true, state: navState }); | ||
appHistory.navigate("#bar"); | ||
appHistory.onnavigate = t.step_func_done(e => { | ||
assert_not_equals(e.destination, null); | ||
assert_not_equals(e.destination.getState(), undefined); | ||
assert_not_equals(e.destination.getState(), e.destination.getState()); | ||
}); | ||
appHistory.back(); | ||
}), 0); | ||
}, "navigate event destination.getState() on back/forward navigation"); | ||
</script> |
19 changes: 19 additions & 0 deletions
19
...tests/wpt_internal/app-history/navigate-event/navigate-destination-getState-navigate.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
async_test(t => { | ||
// step_timeout because blink doesn't create history entries if onload has not | ||
// yet completed. | ||
window.onload = () => t.step_timeout(() => { | ||
let navState = { statevar: "state" }; | ||
appHistory.onnavigate = t.step_func_done(e => { | ||
assert_not_equals(e.destination, null); | ||
assert_not_equals(e.destination.getState(), undefined); | ||
assert_equals(e.destination.getState().statevar, "state"); | ||
assert_not_equals(e.destination.getState(), e.destination.getState()); | ||
}); | ||
appHistory.navigate("#foo", { state: navState }); | ||
}, 0); | ||
}, "navigate event destination.getState() should be the state given to navigate()"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.