Skip to content

PUC Automated Testing on iOS #279

@justadreamer

Description

@justadreamer

Motivation

Introduce regression testing PUC not rendering certain creatives (uncovered as part of #275)

Background

Detailed postmortem doc is shared in the Slack channel (let me know if you want a link either via slack or email), but it comes down to this:

  • creatives often contain document.write because they expect to be rendered in an iframe not plainly output into the document
  • unlike web on mobile PUC actually dumps content directly into the document, not iframe
  • script tags contained in this rendered content after being dynamically added are thus treated as async loaded
  • script loading and execution happens after document stream is closed
  • if the script contains a document.write - it is blocked by the WebView because it otherwise would overwrite the document content
  • we get an effect of the ad not rendering as described in iOS Mobile Ads not rendering since v1.17 #275
  • this is why we needed postscribe that was removed as part of the Remove postscribe dependency #179, PRs: Replace PostScribe in the PUC #246 and Resolve issue where scripts in markup never execute on mobile #274
  • postscribe actually kept the document stream open and replaced document.write calls in the async scripts so that the content is appended to the document, not overwriting it - this allowed such dynamically added scripts render nested content properly
  • thus for now we need to restore postscribe as part of Restore Postscribe #278 but an automated test would be good to justify that the ads are rendering on iOS in the future when we try to replace it again :)

Essential Components

  • You need to build and serve (or proxy-replace) a locally built PUC
  • You need to serve (or proxy-replace) a cache response (mobile uses cache)
  • The minimum adm for the cache response
<script src=\"https://example.com/test-creative.js\"></script>
  • Map example.com to 127.0.0.1 via /etc/hosts
  • Serve this script using caddy or other server with tls (iOS wants https:// otherwise won't load) Caddyfile:
example.com {
    root * .
    file_server
    tls internal
}
  • you must serve this as a test-creative.js: (a distilled version):
document.write("<h1>Test</h1>")
  • Once you are able to render this injected PUC and injected adm on mobile as part of the iOS Mobile Demo App - you can setup an automation via XCUITest
  • testing should be done on macos-latest (arm64) github runner (ask ChatGPT how to set it up)

Objectives

  1. Setup a creative on a GAM account used for Prebid Mobile Apps testing that would point at a localhost URL for PUC and a localhost URL for cache response - you can hardcode those - you will be serving them.
  2. Write a XCUITest that would verify the creative rendered.
  3. Implement a script that starts all the localhost servers and starts an xcuitest.
  4. Create a github action that would setup the environment and run the script on a macos-latest github runner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions