or run

npx @tessl/cli init
Log in

Version

Files

docs

browser-contexts.mdbrowser-management.mdelement-handling.mdindex.mdinput-simulation.mdlocators-selectors.mdnetwork-management.mdpage-interaction.md
tile.json

task.mdevals/scenario-3/

Multi-User Session Simulator

Build a tool that simulates multiple user sessions using isolated browser contexts to test session management and cookie isolation.

Requirements

Create a session simulator that manages multiple isolated user sessions. Each session should:

  • Run in its own browser context with isolated cookies and storage
  • Support setting and retrieving session-specific cookies
  • Maintain complete isolation from other concurrent sessions
  • Provide proper cleanup when sessions end

Functional Specifications

Initialize Browser

Create a function to launch and configure the browser instance for session management.

Create User Session

Implement a function that creates a new isolated session with:

  • A dedicated browser context for isolation
  • Initial session cookies (username and session token)
  • The ability to navigate to URLs

Manage Session Cookies

Implement functions to:

  • Set cookies for a specific session (with domain, path, and security options)
  • Retrieve all cookies from a session

Verify Session Isolation

Create a verification function that confirms two sessions maintain separate cookies when accessing the same URL.

Cleanup Sessions

Implement cleanup functions to:

  • Close individual sessions and their contexts
  • Shut down the browser instance

Test Cases

  • Creating two isolated sessions and verifying cookies don't overlap @test
  • Setting and retrieving session cookies correctly @test
  • Multiple concurrent sessions maintain independence @test

Implementation

@generates

API

/**
 * Initialize the browser for session simulation
 * @param {Object} options - Browser launch options
 * @param {string} options.executablePath - Path to browser executable
 * @returns {Promise<Browser>} Browser instance
 */
async function initBrowser(options) {
  // Implementation
}

/**
 * Create a new isolated user session
 * @param {Browser} browser - Browser instance
 * @param {Object} sessionData - Session initialization data
 * @param {string} sessionData.username - Username for the session
 * @param {string} sessionData.sessionToken - Session authentication token
 * @param {string} sessionData.domain - Cookie domain
 * @returns {Promise<UserSession>} Session object with context and helper methods
 */
async function createUserSession(browser, sessionData) {
  // Implementation
}

/**
 * Get all cookies for a session
 * @param {UserSession} session - User session object
 * @param {string} [url] - Optional URL to filter cookies
 * @returns {Promise<Array>} Array of cookie objects
 */
async function getSessionCookies(session, url) {
  // Implementation
}

/**
 * Verify that two sessions are properly isolated
 * @param {UserSession} session1 - First session
 * @param {UserSession} session2 - Second session
 * @param {string} testUrl - URL to test with both sessions
 * @returns {Promise<boolean>} True if sessions are properly isolated
 */
async function verifySessionIsolation(session1, session2, testUrl) {
  // Implementation
}

/**
 * Close a user session and cleanup resources
 * @param {UserSession} session - Session to close
 * @returns {Promise<void>}
 */
async function closeSession(session) {
  // Implementation
}

/**
 * Close browser and cleanup all resources
 * @param {Browser} browser - Browser instance to close
 * @returns {Promise<void>}
 */
async function cleanup(browser) {
  // Implementation
}

Dependencies { .dependencies }

puppeteer-core { .dependency }

Provides browser automation and context management capabilities.