dart-sdk/tests/lib/html/window_test.dart
Srujan Gaddam b859e00908 Reland "[dart:html] Throw exception if Window.open opens null window" and
"[dart:html] Move NullWindowException to implementation"

This is a revert of bd3e6fa1a3 and
2b250992f9.

This adds some small code change to avoid a null-assertion being emitted
that would lead to a browser SecurityError.

CoreLibraryReviewExempt: Reland.
Change-Id: Iab52bb728b14fd0b2378b8923b0e1ea8ea930b12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311922
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-07-06 15:50:48 +00:00

26 lines
822 B
Dart

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:html';
import 'package:expect/minitest.dart';
main() {
test('scrollXY', () {
expect(window.scrollX, 0);
expect(window.scrollY, 0);
});
test('open', () {
final valid = window.open('', 'blank');
valid.closed;
// A blank page with no access to the original window (noopener) should
// result in null.
final invalid = window.open('', 'invalid', 'noopener=true');
try {
// Should result in an exception since the underlying window is null.
invalid.closed;
fail('Expected invalid.closed to throw.');
} on NullWindowException {}
});
}