Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
RELNOTES[INC]: Remove the fourth parameter passed to window.open.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 388466253
Change-Id: I4d9af2be5d074d8a4994d822fe4293538f2a9f02
  • Loading branch information
Closure Team authored and kjin committed Aug 3, 2021
1 parent 0c7b068 commit 5d49bd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
16 changes: 6 additions & 10 deletions closure/goog/dom/safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,9 @@ goog.dom.safe.replaceLocation = function(loc, url) {
* legacy reasons. Pass goog.string.Const if possible.
* @param {string=} opt_specs Comma-separated list of specifications, same as
* in window.open().
* @param {boolean=} opt_replace Whether to replace the current entry in browser
* history, same as in window.open().
* @return {Window} Window the url was opened in.
*/
goog.dom.safe.openInWindow = function(
url, opt_openerWin, opt_name, opt_specs, opt_replace) {
goog.dom.safe.openInWindow = function(url, opt_openerWin, opt_name, opt_specs) {
'use strict';
/** @type {!goog.html.SafeUrl} */
var safeUrl;
Expand All @@ -803,12 +800,11 @@ goog.dom.safe.openInWindow = function(
var name = opt_name instanceof goog.string.Const ?
goog.string.Const.unwrap(opt_name) :
opt_name || '';
// Do not pass opt_specs and opt_replace to window.open unless they were
// provided by the caller. IE11 will use it as a signal to open a new window
// rather than a new tab (even if they're undefined).
if (opt_specs !== undefined || opt_replace !== undefined) {
return win.open(
goog.html.SafeUrl.unwrap(safeUrl), name, opt_specs, opt_replace);
// Do not pass opt_specs to window.open unless it was provided by the caller.
// IE11 will use it as a signal to open a new window rather than a new tab
// (even if it is undefined).
if (opt_specs !== undefined) {
return win.open(goog.html.SafeUrl.unwrap(safeUrl), name, opt_specs);
} else {
return win.open(goog.html.SafeUrl.unwrap(safeUrl), name);
}
Expand Down
9 changes: 4 additions & 5 deletions closure/goog/dom/safe_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,12 @@ testSuite({
/** @type {?} */ (googTesting.createMethodMock(window, 'open'));
const fakeWindow = {};

mockWindowOpen('about:invalid#zClosurez', 'name', 'specs', true)
mockWindowOpen('about:invalid#zClosurez', 'name', 'specs')
.$returns(fakeWindow);
mockWindowOpen.$replay();
let retVal = withAssertionFailure(
() => safe.openInWindow(
'javascript:evil();', window, Const.from('name'), 'specs', true));
'javascript:evil();', window, Const.from('name'), 'specs'));
mockWindowOpen.$verify();
assertEquals(
'openInWindow should return the created window', fakeWindow, retVal);
Expand All @@ -812,11 +812,10 @@ testSuite({
retVal = null;

const safeUrl = SafeUrl.fromConstant(Const.from('javascript:trusted();'));
mockWindowOpen('javascript:trusted();', 'name', 'specs', true)
mockWindowOpen('javascript:trusted();', 'name', 'specs')
.$returns(fakeWindow);
mockWindowOpen.$replay();
retVal =
safe.openInWindow(safeUrl, window, Const.from('name'), 'specs', true);
retVal = safe.openInWindow(safeUrl, window, Const.from('name'), 'specs');
mockWindowOpen.$verify();
assertEquals(
'openInWindow should return the created window', fakeWindow, retVal);
Expand Down

0 comments on commit 5d49bd0

Please sign in to comment.