diff --git a/demo_frame.js b/demo_frame.js index 37fad5d..5d7aaa8 100644 --- a/demo_frame.js +++ b/demo_frame.js @@ -132,27 +132,39 @@ module.exports = function(node) { txt = txt.replace(/ high) { + // height reading (lower); The range/tolerance logic is added to prevent + // the continous shrinking of the iframe + var currentHeight = parseInt(computed.height, 10); + if (currentHeight < low || currentHeight > high) { iframe.style.height = Math.min(high, 600) + "px"; } diff --git a/test.js b/test.js index fffcdd6..6447235 100644 --- a/test.js +++ b/test.js @@ -388,6 +388,34 @@ describe("bit-docs-tag-demo", function() { }); }); + describe("resize iframe logic adds up border/padding/margin", function() { + before(function() { + return ctx.browser + .newPage() + .then(function(p) { + ctx.page = p; + return ctx.page.goto("http://127.0.0.1:8081/test/temp/heightBoxModel.html"); + }) + .then(function() { + return ctx.page.waitForFunction(function() { + var iframe = document.querySelector("iframe"); + return iframe && iframe.style.height === "600px"; + }); + }); + }); + + it("resizes height up to 600px", function() { + ctx.page + .evaluate(function() { + return document.querySelector("iframe").style.height; + }) + .then(function(height) { + assert.equal(height, "600px"); + }); + }); + }); + + describe("multiple instances", function() { this.timeout(8000); @@ -420,8 +448,8 @@ describe("bit-docs-tag-demo", function() { }; }) .then(function(r) { - assert.equal(r.wrappers, 5, "four wrappers exists"); - assert.equal(r.injected, 5, "four injected into wrappers"); + assert.equal(r.wrappers, 6, "four wrappers exists"); + assert.equal(r.injected, 6, "four injected into wrappers"); }); }); }); diff --git a/test/demos/demo-height-box-model.html b/test/demos/demo-height-box-model.html new file mode 100644 index 0000000..58a29cc --- /dev/null +++ b/test/demos/demo-height-box-model.html @@ -0,0 +1,12 @@ +
+ diff --git a/test/generate.js b/test/generate.js index 4f9fb86..171fd70 100644 --- a/test/generate.js +++ b/test/generate.js @@ -16,7 +16,8 @@ function allDemos() { "demo-without-ids", "demo-without-js", "demo-complex", - "demo-height" + "demo-height", + "demo-height-box-model" ] .map(function(demo) { return "

" + demo + "

" + makeWrapper(demo); @@ -45,6 +46,10 @@ var docMap = Promise.resolve({ name: "height", body: makeWrapper("demo-height") }, + heightBoxModel: { + name: "heightBoxModel", + body: makeWrapper("demo-height-box-model") + }, index: { name: "index", body: allDemos()