tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_opengraph.js (2504B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /**
      6 * Tests that the page data service can parse Open Graph metadata.
      7 */
      8 
      9 add_task(async function test_type_website() {
     10  await verifyPageData(
     11    `
     12      <!DOCTYPE html>
     13      <html>
     14      <head>
     15        <title>Internet for people, not profit — Mozilla</title>
     16        <meta property="og:type" content="website">
     17        <meta property="og:site_name" content="Mozilla">
     18        <meta property="og:url" content="https://www.mozilla.org/">
     19        <meta property="og:image" content="https://example.com/preview-image">
     20        <meta property="og:title" content="Internet for people, not profit">
     21        <!-- We expect the test will ignore tags the parser does not recognize. -->
     22        <meta property="og:locale" content="en_CA">
     23        <meta property="og:description" content="Mozilla is the not-for-profit behind the lightning fast Firefox browser. We put people over profit to give everyone more power online.">
     24      </head>
     25      <body>
     26        <p>Test page</p>
     27      </body>
     28      </html>
     29    `,
     30    {
     31      siteName: "Mozilla",
     32      description:
     33        "Mozilla is the not-for-profit behind the lightning fast Firefox browser. We put people over profit to give everyone more power online.",
     34      image: "https://example.com/preview-image",
     35      data: {},
     36    }
     37  );
     38 });
     39 
     40 add_task(async function test_type_movie() {
     41  await verifyPageData(
     42    `
     43      <!DOCTYPE html>
     44      <html>
     45      <head>
     46        <title>Code Rush (TV Movie 2000)</title>
     47        <meta property="og:url" content="https://www.imdb.com/title/tt0499004/"/>
     48        <!-- Omitting og:site_name to test that the parser doesn't break on missing tags. -->
     49        <meta property="og:title" content="Code Rush (TV Movie 2000) - IMDb"/>
     50        <meta property="og:description" content="This is the description of the movie."/>
     51        <meta property="og:type" content="video.movie"/>
     52        <meta property="og:image" content="https://example.com/preview-code-rush"/>
     53        <meta property="og:image:height" content="750"/>
     54        <meta property="og:image:width" content="1000"/>
     55      </head>
     56      <body>
     57        <p>Test page</p>
     58      </body>
     59      </html>
     60    `,
     61    {
     62      image: "https://example.com/preview-code-rush",
     63      description: "This is the description of the movie.",
     64      data: {},
     65    }
     66  );
     67 });