blob: aa3e6c04424c1b36161a906d52eb0a490b1dccde [file] [log] [blame]
// Copyright (c) 2014, 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.
// @dart = 2.9
/// @assertion final documentOffset
/// Provides the coordinates of the element relative to the top of the document.
/// @description Checks that if there is no scroll, it should be equal to offset
/// of client rectangle.
import "dart:html";
import "../../../Utils/expect.dart";
main() {
var x = new Element.html('<div>First - div</div>');
document.body.append(x);
x = new Element.html('<iframe>Second - Iframe</iframe>');
x.style.margin = '10px';
document.body.append(x);
var r = x.getBoundingClientRect();
var off = x.documentOffset;
Expect.approxEquals(r.left, off.x, 1, 'left');
Expect.approxEquals(r.top, off.y, 1, 'top');
}