Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: LayoutTests/fast/frames/resources/frame-programmatic-resize.js

Issue 427563002: Remove HTMLFrameElement.width/height (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix tests Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 var _testFrame; 1 var _testFrame;
2 var _testFrameId; // We keep the id of the test frame to make it easier for a pe rson to interpret the test results. 2 var _testFrameId; // We keep the id of the test frame to make it easier for a pe rson to interpret the test results.
3 3
4 function setTestFrameById(id) 4 function setTestFrameById(id)
5 { 5 {
6 _testFrameId = id; 6 _testFrameId = id;
7 _testFrame = document.getElementById(id); 7 _testFrame = document.getElementById(id);
8 } 8 }
9 9
10 function deltaWidth() 10 function deltaWidth()
11 { 11 {
12 return 10; // A resonable amount to be able to detect that the frame width c hanged. 12 return 10; // A resonable amount to be able to detect that the frame width c hanged.
13 } 13 }
14 14
15 function shouldAllowFrameResize() 15 function shouldAllowFrameResize()
16 { 16 {
17 shouldAllowFrameResizeAfterProcessingFrame(function(frame) { /* Do nothing. */}); 17 shouldAllowFrameResizeAfterProcessingFrame(function(frame) { /* Do nothing. */});
18 } 18 }
19 19
20 function shouldDisallowFrameResize() 20 function shouldDisallowFrameResize()
21 { 21 {
22 shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { /* Do nothin g. */}) 22 shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { /* Do nothin g. */})
23 } 23 }
24 24
25 function shouldDisallowFrameResizeAfterProcessingFrame(processFrameFunction) 25 function shouldDisallowFrameResizeAfterProcessingFrame(processFrameFunction)
26 { 26 {
27 var expectedWidth = _testFrame.width; 27 var expectedWidth = _testFrame.getBoundingClientRect().width;
28 processFrameFunction(_testFrame); 28 processFrameFunction(_testFrame);
29 resizeTestFrameBy(deltaWidth()); 29 resizeTestFrameBy(deltaWidth());
30 checkTestFrameWidthEquals(expectedWidth); 30 checkTestFrameWidthEquals(expectedWidth);
31 } 31 }
32 32
33 function shouldAllowFrameResizeAfterProcessingFrame(processFrameFunction) 33 function shouldAllowFrameResizeAfterProcessingFrame(processFrameFunction)
34 { 34 {
35 var expectedWidth = _testFrame.width + deltaWidth(); 35 var expectedWidth = _testFrame.getBoundingClientRect().width + deltaWidth();
36 processFrameFunction(_testFrame); 36 processFrameFunction(_testFrame);
37 resizeTestFrameBy(deltaWidth()); 37 resizeTestFrameBy(deltaWidth());
38 checkTestFrameWidthEquals(expectedWidth); 38 checkTestFrameWidthEquals(expectedWidth);
39 } 39 }
40 40
41 function checkTestFrameWidthEquals(expectedWidth) 41 function checkTestFrameWidthEquals(expectedWidth)
42 { 42 {
43 if (_testFrame.width === expectedWidth) 43 if (_testFrame.getBoundingClientRect().width === expectedWidth)
44 log('PASS document.getElementById("' + _testFrameId + '").width is ' + e xpectedWidth); 44 log('PASS document.getElementById("' + _testFrameId + '").getBoundingCli entRect().width is ' + expectedWidth);
45 else 45 else
46 log('FAIL document.getElementById("' + _testFrameId + '").width should b e ' + expectedWidth + '. Was ' + _testFrame.width + '.'); 46 log('FAIL document.getElementById("' + _testFrameId + '").getBoundingCli entRect().width should be ' + expectedWidth + '. Was ' + _testFrame.getBoundingC lientRect().width + '.');
47 } 47 }
48 48
49 function resizeTestFrameBy(deltaWidthInPixels) 49 function resizeTestFrameBy(deltaWidthInPixels)
50 { 50 {
51 var borderWidth = parseInt(_testFrame.parentNode.getAttribute("border")); 51 var borderWidth = parseInt(_testFrame.parentNode.getAttribute("border"));
52 52
53 var startX = _testFrame.offsetWidth + borderWidth / 2; 53 var startX = _testFrame.offsetWidth + borderWidth / 2;
54 var startY = _testFrame.offsetHeight / 2; 54 var startY = _testFrame.offsetHeight / 2;
55 var endX = startX + deltaWidthInPixels; 55 var endX = startX + deltaWidthInPixels;
56 var endY = startY; 56 var endY = startY;
57 57
58 eventSender.mouseMoveTo(startX, startY); 58 eventSender.mouseMoveTo(startX, startY);
59 eventSender.mouseDown(); 59 eventSender.mouseDown();
60 eventSender.leapForward(100); 60 eventSender.leapForward(100);
61 eventSender.mouseMoveTo(endX, endY); 61 eventSender.mouseMoveTo(endX, endY);
62 eventSender.mouseUp(); 62 eventSender.mouseUp();
63 } 63 }
64 64
65 function log(message) 65 function log(message)
66 { 66 {
67 document.getElementById("results").contentDocument.getElementById("console") .appendChild(document.createTextNode(message + "\n")); 67 document.getElementById("results").contentDocument.getElementById("console") .appendChild(document.createTextNode(message + "\n"));
68 } 68 }
69 69
70 function description(message) 70 function description(message)
71 { 71 {
72 document.getElementById("results").contentDocument.getElementById("descripti on").innerText = message; 72 document.getElementById("results").contentDocument.getElementById("descripti on").innerText = message;
73 } 73 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/frames/frames-with-frameborder-zero-can-be-resized.html ('k') | Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698