Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Add test for new iOS 8.0 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Vaillancourt committed Sep 30, 2014
1 parent e614122 commit db6aeb4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
72 changes: 72 additions & 0 deletions test/context-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/test/qunit/qunit.css">
<script src="/test/qunit/qunit.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/lib/underscore.js"></script>
<script>
// externals.js dependencies:
// - jquery
// - underscore
// - Mobify.(config.tagVersion|_|$|timing.addPoint)
// - jquery.mapattributes.js
// - unmobify

// Fake out the tag.
Mobify = {
config: {tagVersion: '7.0.0'},
_: _,
$: $,
timing: {addPoint: function(){}}
}
</script>
<script src="/lib/jquery/jquery.mapattributes.js"></script>
<script src="/api/externals.js"></script>
<script src="/unmobify.js"></script>
<script src="/api/data2.js"></script>
<script src="/api/stack.js"></script>
<script src="/api/cont.js"></script>
</head>
<body>
<!--
Usage:
# Run test-server for checkout folder.
$ node test/test-server.js
# Navigate to this page:
$ http://127.0.0.1:8001/test/context-test.html
-->
<h1 id="qunit-header">QUnit Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>

<script>
// There is a bug on iOS 8.0 where:
// `body`.innerHTML = '<form></form><form></form>';
// produces the following elements:
// `<form><form></form></form>`
//
// This test ensures that capturing works as expected.
//
asyncTest('Mobify.html.extractDOM correctly extracts document with two sibbling forms', function() {
var $iframe = $('<iframe src="/test/fixtures-externals/plaintext-sibbling-forms.html">');

$iframe.one('load', function() {
var doc = $iframe.get(0).contentDocument;
var content = Mobify.externals.grabContent(doc);
var children = content.$body.children();

equal(children.length, 2, 'extracted body has two children');
equal(children[0].nodeName, 'FORM', 'first child element is a form');
equal(children[1].nodeName, 'FORM', 'second child element is a form');

start();
});
$('body').append($iframe);
});
</script>
<body>
</html>
13 changes: 13 additions & 0 deletions test/fixtures-externals/plaintext-sibbling-forms.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<script>
// Simulate mobify
document.write("<plaintext style=\"display:none\">");
</script>
</head>
<body>
<form></form>
<form></form>
</body>
</html>

0 comments on commit db6aeb4

Please sign in to comment.