diff --git a/data/code/backbone-umd.js b/data/code/backbone-umd.js new file mode 100644 index 0000000..4bddc08 --- /dev/null +++ b/data/code/backbone-umd.js @@ -0,0 +1,14 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['underscore', 'jquery', 'exports'], function(_, $, exports) { + root.Backbone = factory(root, exports, _, $); + }); + } else if (typeof exports !== 'undefined') { + var _ = require('underscore'); + factory(root, exports, _); + } else { + root.Backbone = factory(root, {}, root._, root.$); + } +}(this, function(root, Backbone, _, $) { + // Backbone… +})); diff --git a/data/code/backbone.js b/data/code/backbone.js new file mode 100644 index 0000000..befac1e --- /dev/null +++ b/data/code/backbone.js @@ -0,0 +1,7 @@ +var phantom = phantom || {exit: function () {}}; +var _ = require('../../vendor/underscore/underscore'); +phantom.injectJs('../../vendor/backbone/backbone.js'); +console.log(_.toString()); +console.log(Backbone.View.toString()); +phantom.exit(); +//module.exports = Backbone; diff --git a/data/code/crash.js b/data/code/crash.js index e846217..405f959 100644 --- a/data/code/crash.js +++ b/data/code/crash.js @@ -1,8 +1,8 @@ -function onLoad() { - console.log(this.responseText); -} - -var request = new XMLHttpRequest(); -request.onload = onLoad; -request.open('get', 'http://localhost:8000/', true); -request.send(); +var phantom = this.phantom || {exit: function () {}}; +var page = require('webpage').create(); +// code, code, code… +page.open('about:blank', function () { + page.close(); + console.log('☮ out!'); + phantom.exit(); +}); diff --git a/data/code/prototypes.js b/data/code/prototypes.js index abbda08..ec799dd 100644 --- a/data/code/prototypes.js +++ b/data/code/prototypes.js @@ -1,13 +1,10 @@ -(function (phantom) { - console.log('bind:', typeof Function.prototype.bind); - console.log('9 === parseInt("09"):', 9 === parseInt('09')); +var phantom = this.phantom || {exit: function () {}}; +console.log('bind:', typeof Function.prototype.bind); +console.log('9 === parseInt("09"):', 9 === parseInt('09')); - console.log('map:', typeof Array.prototype.map); - console.log('reduce:', typeof Array.prototype.reduce); - console.log('filter:', typeof Array.prototype.filter); - console.log('Object.create:', typeof Object.create); +console.log('map:', typeof Array.prototype.map); +console.log('reduce:', typeof Array.prototype.reduce); +console.log('filter:', typeof Array.prototype.filter); +console.log('Object.create:', typeof Object.create); - if (phantom) { - phantom.exit(); - } -}(this.phantom)); +phantom.exit(); diff --git a/data/code/some-test.js b/data/code/some-test.js new file mode 100644 index 0000000..9b8bd63 --- /dev/null +++ b/data/code/some-test.js @@ -0,0 +1,5 @@ +describe('some test', function () { + it('→ some test case', function () { + expect(1 + 1).toBe(2); + }); +}); diff --git a/data/code/test.js b/data/code/test.js new file mode 100644 index 0000000..54ad373 --- /dev/null +++ b/data/code/test.js @@ -0,0 +1,15 @@ +phantom.injectJs('../../vendor/jasmine/lib/jasmine-core/jasmine.js'); +var consoleFns = require('../../vendor/jasmine/lib/console/console.js'); +var jasmine = jasmineRequire.core(jasmineRequire); +consoleFns.console(consoleFns, jasmine); + +var globals = jasmineRequire.interface(jasmine, jasmine.getEnv()); +for (var property in globals) this[property] = globals[property]; + +jasmine.getEnv().addReporter(new jasmine.ConsoleReporter({ + print: function print(msg) { console.log(msg); }, + onComplete: function exit(success) { phantom.exit(success ? 0 : 1); } +})); + +phantom.injectJs('./some-test.js'); +jasmine.getEnv().execute(); diff --git a/data/code/use-after-free.js b/data/code/use-after-free.js index 679d261..433b7cc 100644 --- a/data/code/use-after-free.js +++ b/data/code/use-after-free.js @@ -1,10 +1,9 @@ -(function (phantom) { - var foo = {bar: {baz: 123}}; - delete foo.bar; - try { - console.log(foo.bar.baz); - } catch (err) { - console.log(err); - phantom && phantom.exit(); - } -}(this.phantom)); +var phantom = this.phantom || {exit: function () {}}; +var foo = {bar: {baz: 123}}; +delete foo.bar; +try { + console.log(foo.bar.baz); +} catch (err) { + console.log(err); + phantom.exit(); +} diff --git a/data/copy/code-share.md b/data/copy/code-share.md new file mode 100644 index 0000000..17224ad --- /dev/null +++ b/data/copy/code-share.md @@ -0,0 +1,6 @@ +# Sharing is Caring + +- Global variables +- CommonJS +- AMD +- ES6 modules diff --git a/data/copy/crash-explain.md b/data/copy/crash-explain.md new file mode 100644 index 0000000..72aabb1 --- /dev/null +++ b/data/copy/crash-explain.md @@ -0,0 +1,5 @@ +# Use After Free + +- Create webpage object in JavaScript +- Close webpage in JavaScript +- Do something with webpage in JavaScript diff --git a/data/copy/fin.md b/data/copy/fin.md new file mode 100644 index 0000000..f5250c6 --- /dev/null +++ b/data/copy/fin.md @@ -0,0 +1,2 @@ +# Thanks! +## Q&A diff --git a/data/copy/other-awesome.md b/data/copy/other-awesome.md new file mode 100644 index 0000000..b0f7528 --- /dev/null +++ b/data/copy/other-awesome.md @@ -0,0 +1,6 @@ +# More goodies + + - The `--remote-debugger-port [debug-port]` flag + - Web server module + - Use a WebSocket in a webpage + - So much awesomeness diff --git a/data/copy/testing.md b/data/copy/testing.md new file mode 100644 index 0000000..f00b526 --- /dev/null +++ b/data/copy/testing.md @@ -0,0 +1 @@ +# Testing diff --git a/data/copy/umd.md b/data/copy/umd.md new file mode 100644 index 0000000..6af4daa --- /dev/null +++ b/data/copy/umd.md @@ -0,0 +1 @@ +# Backbone's UMD diff --git a/data/slide/09.json b/data/slide/09.json index c05568a..de2da20 100644 --- a/data/slide/09.json +++ b/data/slide/09.json @@ -1,4 +1,4 @@ { - "copy": "only-title", + "copy": "crash-explain", "code": "crash" } diff --git a/data/slide/10.json b/data/slide/10.json index 2d06af8..468ceb8 100644 --- a/data/slide/10.json +++ b/data/slide/10.json @@ -1,4 +1,4 @@ { "copy": "js-runtime", - "code": "html5" + "code": "prototypes" } diff --git a/data/slide/11.json b/data/slide/11.json index 468ceb8..54efe99 100644 --- a/data/slide/11.json +++ b/data/slide/11.json @@ -1,4 +1,3 @@ { - "copy": "js-runtime", - "code": "prototypes" + "copy": "code-share" } diff --git a/data/slide/12.json b/data/slide/12.json new file mode 100644 index 0000000..3662815 --- /dev/null +++ b/data/slide/12.json @@ -0,0 +1,4 @@ +{ + "copy": "umd", + "code": "backbone-umd" +} diff --git a/data/slide/13.json b/data/slide/13.json new file mode 100644 index 0000000..55d3be8 --- /dev/null +++ b/data/slide/13.json @@ -0,0 +1,4 @@ +{ + "copy": "only-title", + "code": "backbone" +} diff --git a/data/slide/14.json b/data/slide/14.json new file mode 100644 index 0000000..a12e499 --- /dev/null +++ b/data/slide/14.json @@ -0,0 +1,4 @@ +{ + "copy": "testing", + "code": "some-test" +} diff --git a/data/slide/15.json b/data/slide/15.json new file mode 100644 index 0000000..db310c4 --- /dev/null +++ b/data/slide/15.json @@ -0,0 +1,4 @@ +{ + "copy": "testing", + "code": "test" +} diff --git a/data/slide/16.json b/data/slide/16.json new file mode 100644 index 0000000..2a35e99 --- /dev/null +++ b/data/slide/16.json @@ -0,0 +1,3 @@ +{ + "copy": "other-awesome" +} diff --git a/data/slide/17.json b/data/slide/17.json new file mode 100644 index 0000000..b1dbd4c --- /dev/null +++ b/data/slide/17.json @@ -0,0 +1,3 @@ +{ + "copy": "fin" +}