Skip to content

Commit

Permalink
Add a way to check if Html5History is using the fragment for the to…
Browse files Browse the repository at this point in the history
…ken.

RELNOTES: Add a way to check if `Html5History` is using the fragment for the token.

PiperOrigin-RevId: 530306434
Change-Id: I3032298a3e4e027b5c87ff9a94276228a29b68fb
  • Loading branch information
Closure Team authored and Copybara-Service committed May 8, 2023
1 parent c92fcbd commit a6fa5b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions closure/goog/history/html5history.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ goog.history.Html5History.prototype.disposeInternal = function() {
};


/** @return {boolean} Whether the fragment is used to store tokens. */
goog.history.Html5History.prototype.getUseFragment = function() {
return this.useFragment_;
};


/**
* Sets whether to use the fragment to store tokens.
* @param {boolean} useFragment Whether to use the fragment.
Expand Down
20 changes: 20 additions & 0 deletions closure/goog/history/html5history_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ testSuite({
mockControl.$tearDown();
},

testGetUseFragment_false() {
/** @suppress {checkTypes} suppression added to enable type checking */
html5History = new Html5History(mockWindow);
html5History.setUseFragment(false);

const useFragment = html5History.getUseFragment();

assertFalse(useFragment);
},

testGetUseFragment_true() {
/** @suppress {checkTypes} suppression added to enable type checking */
html5History = new Html5History(mockWindow);
html5History.setUseFragment(true);

const useFragment = html5History.getUseFragment();

assertTrue(useFragment);
},

testGetTokenWithoutUsingFragment() {
mockWindow.location.pathname = '/test/something';

Expand Down

0 comments on commit a6fa5b0

Please sign in to comment.