Commit e7d6d83b authored by Juan Corona's avatar Juan Corona

Add more test cases in the multi-frame integration test

The tests are in a response to an issue found when frames get added/removed in quick succession. It was due to the timing of the debounce used in FrameObserver.
This also works to test against possible edge cases and ensures robustness of the feature by going full circle.
parent 253fcc1c
'use strict';
var proxyquire = require('proxyquire');
var isLoaded = require('../../util/frame-util.js').isLoaded;
var isLoaded = require('../../util/frame-util').isLoaded;
var FRAME_ADD_WAIT = require('../../frame-observer').DEBOUNCE_WAIT + 10;
describe('CrossFrame multi-frame scenario', function () {
var fakeAnnotationSync;
......@@ -143,7 +145,7 @@ describe('CrossFrame multi-frame scenario', function () {
'expected dynamically added frame to be modified');
resolve();
});
}, 0);
}, FRAME_ADD_WAIT);
});
});
......@@ -169,4 +171,75 @@ describe('CrossFrame multi-frame scenario', function () {
});
});
it('detects a frame dynamically removed, and added again', function () {
// Create a frame before initializing
var frame = document.createElement('iframe');
container.appendChild(frame);
// Now initialize
crossFrame.pluginInit();
return new Promise(function (resolve) {
isLoaded(frame, function () {
assert(frame.contentDocument.body.hasChildNodes(),
'expected initial frame to be modified');
frame.remove();
// Yield to let the DOM and CrossFrame catch up
setTimeout(function () {
// Add the frame again
container.appendChild(frame);
// Yield again
setTimeout(function () {
isLoaded(frame, function () {
assert(frame.contentDocument.body.hasChildNodes(),
'expected dynamically added frame to be modified');
resolve();
});
}, FRAME_ADD_WAIT);
}, 0);
});
});
});
it('detects a frame dynamically added, removed, and added again', function () {
// Initialize with no initial frame
crossFrame.pluginInit();
// Add a frame to the DOM
var frame = document.createElement('iframe');
container.appendChild(frame);
return new Promise(function (resolve) {
// Yield to let the DOM and CrossFrame catch up
setTimeout(function () {
isLoaded(frame, function () {
assert(frame.contentDocument.body.hasChildNodes(),
'expected dynamically added frame to be modified');
frame.remove();
// Yield again
setTimeout(function () {
// Add the frame again
container.appendChild(frame);
// Yield
setTimeout(function () {
isLoaded(frame, function () {
assert(frame.contentDocument.body.hasChildNodes(),
'expected dynamically added frame to be modified');
resolve();
});
}, FRAME_ADD_WAIT);
}, 0);
});
}, FRAME_ADD_WAIT);
});
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment