Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /svg/coordinate-systems/outer-svg-resize-001o.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>An SVG document in an object element follows the object's size</title>
<link rel="author" title="Felipe Erias" href="mailto:felipeerias@igalia.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
object { display: block; width: 200px; height: 100px; }
</style>
<object id="object" data="/images/green.svg" onload="run()"></object>
<script>
function run() {
const object = document.getElementById('object');
const svg = object.getSVGDocument().documentElement;
test(() => {
assert_equals(svg.getBoundingClientRect().width, 200, 'width');
assert_equals(svg.getBoundingClientRect().height, 100, 'height');
}, 'initial size');
test(() => {
object.style.height = '50px';
assert_equals(svg.getBoundingClientRect().height, 50);
}, 'after changing the height');
test(() => {
object.style.width = '100px';
assert_equals(svg.getBoundingClientRect().width, 100);
}, 'after changing the width');
}
</script>