diff --git a/spec-main/api-deprecate-spec.ts b/spec-main/api-deprecate-spec.ts index d65dc08fde7b..cab807ccfef0 100644 --- a/spec-main/api-deprecate-spec.ts +++ b/spec-main/api-deprecate-spec.ts @@ -2,11 +2,18 @@ import { expect } from 'chai' import { deprecate } from 'electron' describe('deprecate', () => { + let throwing: boolean + beforeEach(() => { + throwing = process.throwDeprecation deprecate.setHandler(null) process.throwDeprecation = true }) + afterEach(() => { + process.throwDeprecation = throwing + }) + it('allows a deprecation handler function to be specified', () => { const messages: string[] = [] diff --git a/spec-main/api-web-contents-spec.ts b/spec-main/api-web-contents-spec.ts index 20e9f5e4ed03..d077ec711085 100644 --- a/spec-main/api-web-contents-spec.ts +++ b/spec-main/api-web-contents-spec.ts @@ -9,6 +9,7 @@ import { emittedOnce } from './events-helpers' import { closeAllWindows } from './window-helpers' import { ifdescribe, ifit } from './spec-helpers' +const pdfjs = require('pdfjs-dist') const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures') const features = process.electronBinding('features') @@ -1447,6 +1448,29 @@ describe('webContents module', () => { expect(data).to.be.an.instanceof(Buffer).that.is.not.empty() }) + it('respects custom settings', async () => { + w.loadFile(path.join(__dirname, 'fixtures', 'api', 'print-to-pdf.html')) + await emittedOnce(w.webContents, 'did-finish-load') + + const data = await w.webContents.printToPDF({ + pageRanges: { + from: 0, + to: 2 + }, + landscape: true + }) + + const doc = await pdfjs.getDocument(data).promise + + // Check that correct # of pages are rendered. + expect(doc.numPages).to.equal(3) + + // Check that PDF is generated in landscape mode. + const firstPage = await doc.getPage(1) + const { width, height } = firstPage.getViewport({ scale: 100 }) + expect(width).to.be.greaterThan(height) + }) + it('does not crash when called multiple times', async () => { const promises = [] for (let i = 0; i < 2; i++) { diff --git a/spec-main/fixtures/api/print-to-pdf.html b/spec-main/fixtures/api/print-to-pdf.html new file mode 100644 index 000000000000..939cad1e62d9 --- /dev/null +++ b/spec-main/fixtures/api/print-to-pdf.html @@ -0,0 +1,1297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The world’s leading software development platform · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + +
+
+ +
+
+
+
+

Built for developers

+

+ GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside 40 million developers. +

+
+
+
+
+
+ + +
+
+
+ + + +
+
+
+
+ + +
+ +
+

Get started with GitHub Enterprise

+

+ Take collaboration to the next level with security and administrative features built for teams. +

+
+
+
+
+ + + + + + + + + + + +

Enterprise

+

Deploy to your environment or the cloud.

+
+ Start a free trial +
+
+
+ + +

Talk to us

+

Need help?

+
+ Contact Sales +
+
+
+
+
+ + + + +
+
+
+

See what launched at Universe

+

Say hello to our new GitHub for mobile experience, get more from GitHub Actions and Packages, and learn how we’re shaping the future of software, together.

+
+ +
+
+ + +
+
+

+ More than 2.1 million businesses and organizations use GitHub +

+
    +
  • Airbnb
  • +
  • SAP
  • +
  • IBM
  • +
  • Google
  • +
  • PayPal
  • +
  • Bloomberg
  • +
  • Spotify
  • +
  • Swift
  • +
  • Facebook
  • +
  • Node.js
  • +
  • NASA
  • +
  • Walmart
  • +
+
+
+ + + +
+
+

+ Security and administration +

+

+ Your business needs, met +

+

+ From flexible hosting to granular access controls, we’ve got your security requirements covered. +

+

+ + How GitHub Enterprise works + Learn how GitHub Enterprise works + +

+ +
+
+ Security and administration +
+
+

Code security

+

+ Prevent problems before they happen. Protected branches, signed commits, and required status checks protect your work and help you maintain a high standard for your code. +

+

Access controlled

+

+ Encourage teams to work together while limiting access to those who need it with granular permissions and authentication through SAML/SSO and LDAP. +

+
+
+ +
+
+ + +
+
+

Hosted where you need it

+

Securely and reliably host your work on GitHub using GitHub Enterprise Cloud. Or deploy GitHub Enterprise Server in your own data centers or in a private cloud using Amazon Web Services, Azure, or Google Cloud Platform.

+ + Compare plans + Contact Sales for more information +
+
+ +
+
+ +
+
+
+

+ Integrations +

+

+ Build on GitHub +

+

+ Customize your process with GitHub apps and an intuitive API. Integrate the tools you already use or discover new favorites to create a happier, more efficient way of working. +

+

+ Learn about integrations +

+
+ +
+
Slack
+
ZenHub
+
Travis CI
+
Atom
+
Circle CI
+
Google
+
Code Climate
+
+ +
+

+ Sometimes, there’s more than one tool for the job. Why not try something new? +

+

+ + Browse GitHub Marketplace + +

+
+
+
+ +
+
+

+ Community +

+

+ Welcome home,
developers +

+

+ GitHub is home to the world’s largest community of developers and their projects... +

+
+ + + + + +
+ +
+
+

+ Get started for free — join the millions of developers already using GitHub to share their code, work together, and build amazing things. +

+
+
+
+
+ +
+ +
+ + + + + + +
+ + + You can’t perform that action at this time. +
+ + + + + + + + + + + + + + + + + +
+ + + + diff --git a/spec-main/package.json b/spec-main/package.json index 696a3713fe88..e380987b68f5 100644 --- a/spec-main/package.json +++ b/spec-main/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "chai-as-promised": "^7.1.1", - "dirty-chai": "^2.0.1" + "dirty-chai": "^2.0.1", + "pdfjs-dist": "^2.2.228" } } diff --git a/spec-main/yarn.lock b/spec-main/yarn.lock index 20e1741ae171..1c63cc1531db 100644 --- a/spec-main/yarn.lock +++ b/spec-main/yarn.lock @@ -2,6 +2,26 @@ # yarn lockfile v1 +ajv-keywords@^3.1.0: + version "3.4.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da" + integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ== + +ajv@^6.1.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.11.0.tgz#c3607cbc8ae392d8a5a536f25b21f8e5f3f87fe9" + integrity sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +big.js@^5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" + integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== + chai-as-promised@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-7.1.1.tgz#08645d825deb8696ee61725dbf590c012eb00ca0" @@ -22,7 +42,89 @@ dirty-chai@^2.0.1: "echo@file:fixtures/native-addon/echo": version "0.0.1" +emojis-list@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" + integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k= + +fast-deep-equal@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" + integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json5@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" + integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + dependencies: + minimist "^1.2.0" + +loader-utils@^1.0.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7" + integrity sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA== + dependencies: + big.js "^5.2.2" + emojis-list "^2.0.0" + json5 "^1.0.1" + +minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + +node-ensure@^0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/node-ensure/-/node-ensure-0.0.0.tgz#ecae764150de99861ec5c810fd5d096b183932a7" + integrity sha1-7K52QVDemYYexcgQ/V0Jaxg5Mqc= + +pdfjs-dist@^2.2.228: + version "2.2.228" + resolved "https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-2.2.228.tgz#777b068a0a16c96418433303807c183058b47aaa" + integrity sha512-W5LhYPMS2UKX0ELIa4u+CFCMoox5qQNQElt0bAK2mwz1V8jZL0rvLao+0tBujce84PK6PvWG36Nwr7agCCWFGQ== + dependencies: + node-ensure "^0.0.0" + worker-loader "^2.0.0" + +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + q@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= + +schema-utils@^0.4.0: + version "0.4.7" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187" + integrity sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ== + dependencies: + ajv "^6.1.0" + ajv-keywords "^3.1.0" + +uri-js@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" + integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + dependencies: + punycode "^2.1.0" + +worker-loader@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/worker-loader/-/worker-loader-2.0.0.tgz#45fda3ef76aca815771a89107399ee4119b430ac" + integrity sha512-tnvNp4K3KQOpfRnD20m8xltE3eWh89Ye+5oj7wXEEHKac1P4oZ6p9oTj8/8ExqoSBnk9nu5Pr4nKfQ1hn2APJw== + dependencies: + loader-utils "^1.0.0" + schema-utils "^0.4.0"