Index: third_party/WebKit/LayoutTests/fast/frames/unique-name-all-subframes-have-same-name.html |
diff --git a/third_party/WebKit/LayoutTests/fast/frames/unique-name-all-subframes-have-same-name.html b/third_party/WebKit/LayoutTests/fast/frames/unique-name-all-subframes-have-same-name.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..128eb781f211e758ee17261e922f20daf3a6e8b4 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/frames/unique-name-all-subframes-have-same-name.html |
@@ -0,0 +1,49 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script> |
+function runTest() |
+{ |
+ if (window.testRunner) { |
+ testRunner.dumpAsText(); |
+ testRunner.dumpChildFramesAsText(); |
+ } |
+ |
+ function removeFrameAndAddNewFrame(oldFrameId) { |
+ body = document.getElementById('body'); |
+ oldFrame = document.getElementById(oldFrameId); |
+ body.removeChild(oldFrame); |
+ |
+ // newFrame is added to the frame tree when the parent has the same number of |
+ // children as when frame5 was being added. This will make |
+ // likelyUniqueSuffix the same for frame5 and newFrame - their unique |
+ // name will have to be different in some other way. |
+ newFrame = document.createElement('iframe'); |
+ newFrame.name = "sameName"; |
+ body.appendChild(newFrame); |
+ } |
+ |
+ removeFrameAndAddNewFrame('frame2') |
+ removeFrameAndAddNewFrame('frame3') |
+} |
+</script> |
+</head> |
+<body onload="runTest()" id="body"> |
+<!-- |
+Before https://crrev.com/1968213002 the name generated by |
+FrameTree::generateOldStyleMaybeUniqueName would be assumed to be unique, but |
+in reality could conflict with other names. This scenario is similar, but not |
+the same as https://crbug.com/576969#c3. |
+ |
+Additionaly, this test also exercises a scenario where the new |
+FrameTree::generateLikelyUniqueSuffix can generate a suffix that |
+is not really unique (and where uniquness comes from numberOfTries |
+in FrameTree::ensureUniquenessOfUniqueName). |
+--> |
+<iframe id="frame1" name="sameName"></iframe> |
+<iframe id="frame2" name="sameName"></iframe> |
+<iframe id="frame3" name="sameName"></iframe> |
+<iframe id="frame4" name="sameName"></iframe> |
+<iframe id="frame5" name="sameName"></iframe> |
+</body> |
+</html> |