mobify-capturejs
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -13,2 +13,10 @@ module.exports = function(grunt) { | ||
} | ||
}, | ||
test: { | ||
options: { | ||
hostname: '0.0.0.0', | ||
port: 3001, | ||
base: '.', | ||
debug: true | ||
} | ||
} | ||
@@ -21,3 +29,3 @@ }, | ||
urls: [ | ||
'http://localhost:3000/tests/index.html', | ||
'http://localhost:3001/tests/index.html', | ||
] | ||
@@ -51,3 +59,3 @@ } | ||
urls: [ | ||
'http://localhost:3000/tests/index.html' | ||
'http://localhost:3001/tests/index.html' | ||
], | ||
@@ -58,3 +66,3 @@ concurrency: 16, | ||
browsers: [ //https://saucelabs.com/docs/platforms | ||
{ // Only working version of IE compatable | ||
{ // Only working version of IE compatible | ||
browserName: 'internet explorer', | ||
@@ -64,3 +72,3 @@ platform: 'Windows 2012', | ||
}, | ||
{ // Only working version of IE compatable | ||
{ // Only working version of IE compatible | ||
browserName: 'internet explorer', | ||
@@ -145,28 +153,23 @@ platform: 'Windows 8.1', | ||
}, | ||
s3: { | ||
options: { | ||
access: "public-read", | ||
headers: { "Cache-Control": "public,max-age=1800" }, // cache for 30 min | ||
maxOperations: 6 | ||
}, | ||
aws_s3: { | ||
capturejs: { | ||
options: { | ||
bucket: 'mobify', | ||
gzip: true | ||
CacheControl: "public,max-age=1800", // cache for 30 min | ||
}, | ||
upload: [ | ||
files: [ | ||
{ // unminified dev build | ||
src: "build/capture.js", | ||
src: ["build/capture.js"], | ||
dest: "capturejs/capture-<%= pkg.version %>.js", | ||
}, | ||
{ // unminified dev build to latest | ||
src: "build/capture.js", | ||
src: ["build/capture.js"], | ||
dest: "capturejs/capture-latest.js", | ||
}, | ||
{ // minified production build | ||
src: "build/capture.min.js", | ||
src: ["build/capture.min.js"], | ||
dest: "capturejs/capture-<%= pkg.version %>.min.js", | ||
}, | ||
{ // minified production build to latest | ||
src: "build/capture.min.js", | ||
src: ["build/capture.min.js"], | ||
dest: "capturejs/capture-latest.min.js", | ||
@@ -181,2 +184,3 @@ } | ||
grunt.loadNpmTasks('grunt-contrib-qunit'); | ||
grunt.loadNpmTasks('grunt-aws-s3'); | ||
grunt.loadNpmTasks('grunt-saucelabs'); | ||
@@ -186,9 +190,8 @@ grunt.loadNpmTasks('grunt-browserify'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('grunt-s3'); | ||
grunt.registerTask('build', ['browserify', 'uglify']); | ||
grunt.registerTask('saucelabs', ['test', 'saucelabs-qunit']); | ||
grunt.registerTask('test', ['express', 'qunit']); | ||
grunt.registerTask('serve', ['build', 'express', 'watch']); | ||
grunt.registerTask('deploy', ['s3']); | ||
grunt.registerTask('test', ['build', 'express:test', 'qunit']); | ||
grunt.registerTask('serve', ['build', 'express:capturejs', 'watch']); | ||
grunt.registerTask('deploy', ['aws_s3']); | ||
}; |
{ | ||
"name": "mobify-capturejs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"devDependencies": { | ||
"grunt": "~0.4.0", | ||
"grunt-aws-s3": "^0.14.0", | ||
"grunt-browserify": "~1.3.1", | ||
@@ -11,5 +12,4 @@ "grunt-contrib-qunit": "~0.2.0", | ||
"grunt-express": "~0.3.6", | ||
"grunt-s3": "0.2.0-alpha.3", | ||
"grunt-saucelabs": "8.3.2" | ||
} | ||
} |
@@ -5,2 +5,4 @@ # capture.js | ||
[![npm version](https://badge.fury.io/js/mobify-capturejs.svg)](http://badge.fury.io/js/mobify-capturejs) | ||
## How to use | ||
@@ -42,2 +44,2 @@ | ||
Talk to @jansepar | ||
Talk to @jansepar |
@@ -132,3 +132,3 @@ (function (root, factory) { | ||
callback(capture); | ||
} | ||
}; | ||
@@ -153,3 +153,3 @@ if (Utils.domIsReady(doc)) { | ||
} | ||
} | ||
}; | ||
// backup with polling incase readystatechange doesn't fire | ||
@@ -446,7 +446,9 @@ // (happens with some Android 2.3 browsers) | ||
if (!head.length) { | ||
callback && callback(); | ||
return; | ||
} | ||
var head = head[0]; | ||
var meta = document.createElement('meta'); | ||
head = head[0]; | ||
var meta = doc.createElement('meta'); | ||
meta.setAttribute('name', 'viewport'); | ||
@@ -477,2 +479,5 @@ meta.setAttribute('content', 'width=device-width'); | ||
// Set a flag indicating that we're restoring | ||
this.disabled = true; | ||
Utils.waitForReady(document, function() { | ||
@@ -570,3 +575,7 @@ self.render(self.all(inject)); | ||
if (Capture.isIOS8OrGreater(window.navigator.userAgent)) { | ||
// RTM-367: We don't want to inject a viewport when restoring, because: | ||
// - if a viewport existed in the original source, it'll be restored | ||
// - if a viewport didn't exist in the original source, the browser will | ||
// automatically create one, and our fix isn't needed | ||
if (Capture.isIOS8OrGreater(window.navigator.userAgent) && !this.disabled) { | ||
Capture.ios8AndGreaterScrollFix(document, write); | ||
@@ -573,0 +582,0 @@ } else { |
@@ -6,2 +6,24 @@ require(["mobifyjs/utils", "capture"], function(Utils, Capture) { | ||
/** | ||
* This creates a fake HTML document, then adds the string given to it as the | ||
* content or defaults to the simple markup provided here. | ||
* It simply creates an iframe and then grabs the content. | ||
*/ | ||
var makeDocument = function(docHTML, disable) { | ||
disable = (disable !== undefined) ? disable : true; | ||
docHTML = docHTML || '<html><head></head><body></body></html>'; | ||
if (disable) { | ||
docHTML = Capture.disable(docHTML, 'x-'); | ||
} | ||
var iframe = document.createElement('iframe'); | ||
iframe.style.display = 'none'; | ||
document.body.appendChild(iframe); | ||
var doc = iframe.contentDocument; | ||
doc.open(); | ||
doc.write(docHTML); | ||
doc.close(); | ||
return doc; | ||
}; | ||
// Test disabling attributes that cause resource loading | ||
@@ -22,3 +44,3 @@ test("disable", function() { | ||
ok(compareHTMLStrings(Capture.disable(html, "x-"), expectedHtml), "Passed!" ); | ||
ok(compareHTMLStrings(Capture.disable(html, "x-"), expectedHtml), "Passed!"); | ||
}); | ||
@@ -41,6 +63,6 @@ | ||
ok(compareHTMLStrings(Capture.enable(html, "x-"), expectedHtml), "Passed!" ); | ||
ok(compareHTMLStrings(Capture.enable(html, "x-"), expectedHtml), "Passed!"); | ||
}); | ||
test("openTag", function(){ | ||
test("openTag", function() { | ||
var element = $("#foo-element"); | ||
@@ -52,6 +74,6 @@ var openTag = Capture.openTag(element); | ||
asyncTest("createDocumentFromSource", function(){ | ||
asyncTest("createDocumentFromSource", function() { | ||
var iframe = $("<iframe>", {id: "plaintext-example"}); | ||
iframe.attr("src", "/tests/fixtures/plaintext-example.html") | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -111,6 +133,6 @@ | ||
asyncTest("createDocumentFragmentsStrings - below head tag", function(){ | ||
asyncTest("createDocumentFragmentsStrings - below head tag", function() { | ||
var iframe = $("<iframe>", {id: "plaintext-example9"}); | ||
iframe.attr("src", "/tests/fixtures/plaintext-example.html") | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -120,3 +142,3 @@ | ||
var htmlEl = doc.getElementsByTagName("html")[0].removeAttribute("webdriver") | ||
// alert(doc.getElementsByTagName("html")[0].innerHTML); | ||
// alert(doc.getElementsByTagName("html")[0].innerHTML); | ||
var capture = Capture.createDocumentFragmentsStrings(doc); | ||
@@ -131,6 +153,6 @@ // We're not testing the all function here, let's remove it | ||
asyncTest("createDocumentFragmentsStrings - above head tag", function(){ | ||
asyncTest("createDocumentFragmentsStrings - above head tag", function() { | ||
var iframe = $("<iframe>", {id: "plaintext-example2"}); | ||
iframe.attr("src", "/tests/fixtures/plaintext-above-head-example.html") | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -149,6 +171,6 @@ //alert(doc.getElementsByTagName("html")[0].innerHTML); | ||
asyncTest("createDocumentFragmentsStrings - malformed markup", function(){ | ||
asyncTest("createDocumentFragmentsStrings - malformed markup", function() { | ||
var iframe = $("<iframe>", {id: "plaintext-example4"}); | ||
iframe.attr("src", "/tests/fixtures/plaintext-malformed-markup-example.html") | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -171,6 +193,6 @@ //alert(doc.getElementsByTagName("html")[0].innerHTML); | ||
asyncTest("createDocumentFragmentsStrings - no end head tag", function(){ | ||
asyncTest("createDocumentFragmentsStrings - no end head tag", function() { | ||
var iframe = $("<iframe>", {id: "plaintext-example5"}); | ||
iframe.attr("src", "/tests/fixtures/plaintext-no-end-head-example.html") | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -194,3 +216,3 @@ | ||
iframe.attr("src", "/tests/fixtures/plaintext-script-with-opening-body.html") | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -256,9 +278,8 @@ | ||
// Ensure that a meta viewport tag is added to the document with width = device-width | ||
asyncTest("ios8_0ScrollFix", function() { | ||
var html = document.createElement('html'); | ||
var head = document.createElement('head'); | ||
html.appendChild(head); | ||
var doc = makeDocument(); | ||
Capture.ios8AndGreaterScrollFix(html, function() { | ||
var meta = html.getElementsByTagName('meta')[0] | ||
Capture.ios8AndGreaterScrollFix(doc, function() { | ||
var meta = doc.getElementsByTagName('meta')[0]; | ||
@@ -269,4 +290,3 @@ ok(true, | ||
'meta name is viewport'); | ||
equal(meta.getAttribute('content'), 'width=device-width', | ||
'content is width=device-width'); | ||
equal(meta.getAttribute('content'), 'width=device-width', 'content is width=device-width'); | ||
@@ -277,3 +297,6 @@ start(); | ||
test("cloneAttributes", function(){ | ||
// Do not be alarmed about "Error: INVALID_CHARACTER_ERR: DOM Exception 5" | ||
// during this test --- this is an indication the function is working as | ||
// intended, i.e. it should not clone invalid attributes | ||
test("cloneAttributes", function() { | ||
var el = document.createElement("div"); | ||
@@ -299,3 +322,3 @@ Capture.cloneAttributes("<div class=\"test1 test2\"></div>", el); | ||
test("removeCloseEndTagsAtEndOfString", function(){ | ||
test("removeCloseEndTagsAtEndOfString", function() { | ||
var html = "</div><div>"; | ||
@@ -307,9 +330,9 @@ equal(Capture.removeClosingTagsAtEndOfString(html), html); | ||
ok(compareHTMLStrings(Capture.removeClosingTagsAtEndOfString(html), expectedHtml)); | ||
}) | ||
}); | ||
test("removeTargetSelf", function(){ | ||
test("removeTargetSelf", function() { | ||
var html = "<a href='' target=\"_self\" target='_self'>"; | ||
var expectedHtml = "<a href='' >"; | ||
ok(compareHTMLStrings(Capture.removeTargetSelf(html), expectedHtml)); | ||
}) | ||
}); | ||
@@ -407,4 +430,7 @@ /** | ||
asyncTest("Capture.restore", function(){ | ||
var $iframe = $("<iframe>", {id: "plaintext-example201", src: "/tests/fixtures/plaintext-restore-example.html"}); | ||
asyncTest("Capture.restore", function() { | ||
var $iframe = $("<iframe>", { | ||
id: "plaintext-example201", | ||
src: "/tests/fixtures/plaintext-restore-example.html" | ||
}); | ||
var el = $iframe[0]; | ||
@@ -437,3 +463,3 @@ | ||
$iframe.one('load', function(){ | ||
$iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -453,5 +479,5 @@ | ||
* Regressions test for iOS8 where sibling forms got written out | ||
* as children of eachother. | ||
* as children of each other. | ||
*/ | ||
asyncTest("createDocumentSiblingForms", function(){ | ||
asyncTest("createDocumentSiblingForms", function() { | ||
var iframe = $("<iframe>", { | ||
@@ -461,3 +487,3 @@ id: "plaintext-sibling-forms", | ||
}); | ||
iframe.one('load', function(){ | ||
iframe.one('load', function() { | ||
var doc = this.contentDocument; | ||
@@ -479,5 +505,5 @@ | ||
/** | ||
* Test for ADJS-92: iOS 8.0 smart banner issue. | ||
* Ensure that smart banners above the tag are removed during capturing. | ||
**/ | ||
* Test for ADJS-92: iOS 8.0 smart banner issue. | ||
* Ensure that smart banners above the tag are removed during capturing. | ||
**/ | ||
asyncTest("Remove smart banner when above the tag - iOS8_0 only", function() { | ||
@@ -501,5 +527,5 @@ var $iframe = $("<iframe>", { | ||
/** | ||
* Test for ADJS-92: iOS 8.0 smart banner issue. | ||
* Ensure that smart banners below the tag are not removed on IOS8 | ||
**/ | ||
* Test for ADJS-92: iOS 8.0 smart banner issue. | ||
* Ensure that smart banners below the tag are not removed on IOS8 | ||
**/ | ||
asyncTest("Leave smart banner in place when below the tag - iOS8_0 only", function() { | ||
@@ -506,0 +532,0 @@ var $iframe = $("<iframe>", { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15076
44
861019
78
2