Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push to prod #1678

Merged
merged 23 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"autoload": {
"psr-4": {"WebPageTest\\": "www/models/"}
},
"require-dev": {
"phpunit/phpunit": "^9"
},
Expand Down
14 changes: 14 additions & 0 deletions tests/models/RequestContextTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);

use PHPUnit\Framework\TestCase;
use WebPageTest\RequestContext;

final class RequestContextTest extends TestCase {
public function testConstructorSetsValues() : void {
$global_req = [];
$request = new RequestContext($global_req);
$this->assertEquals($global_req, $request->getRaw());
}
}

?>
3 changes: 1 addition & 2 deletions tests/models/UserTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php declare(strict_types=1);

require_once __DIR__ . '/../../www/models/user.php';

use PHPUnit\Framework\TestCase;
use WebPageTest\User;

final class UserTest extends TestCase {
public function testConstructorSetsValues() : void {
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
return array(
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'WebPageTest\\' => array($baseDir . '/www/models'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
Expand Down
5 changes: 5 additions & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ComposerStaticInit14af0ddfbc16c4126602920a26b812c3
'W' =>
array (
'Webmozart\\Assert\\' => 17,
'WebPageTest\\' => 12,
),
'S' =>
array (
Expand Down Expand Up @@ -60,6 +61,10 @@ class ComposerStaticInit14af0ddfbc16c4126602920a26b812c3
array (
0 => __DIR__ . '/..' . '/webmozart/assert/src',
),
'WebPageTest\\' =>
array (
0 => __DIR__ . '/../..' . '/www/models',
),
'Symfony\\Polyfill\\Ctype\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'c2df17d3f3c56df0b59178ef04b433f636d1abe8',
'reference' => '50f14b8668a3af55a09ac7b745b876f54a6b7a5a',
'name' => '__root__',
'dev' => true,
),
Expand All @@ -16,7 +16,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'c2df17d3f3c56df0b59178ef04b433f636d1abe8',
'reference' => '50f14b8668a3af55a09ac7b745b876f54a6b7a5a',
'dev_requirement' => false,
),
'doctrine/instantiator' => array(
Expand Down
31 changes: 27 additions & 4 deletions www/breakdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,33 @@
<html lang="en-us">
<head>
<title><?php echo $page_title; ?> - WebPageTest Content Breakdown</title>
<script>document.documentElement.classList.add('has-js');</script>

<?php $gaTemplate = 'Content Breakdown'; include ('head.inc'); ?>
</head>
<body>
<body class="result">
<?php
$tab = 'Test Result';
$subtab = 'Content';
include 'header.inc';
?>


<div class="results_main_contain">
<div class="results_main">

<div class="results_and_command">

<div class="results_header">
<h2>Content Breakdown</h2>
<p>How this site's assets are comprised by content type.</p>
</div>

<?php include("testinfo_command-bar.inc"); ?>

</div>

<div id="result" class="results_body">
<?php
if ($isMultistep) {
echo "<a name='quicklinks'><h3>Quicklinks</h3></a>\n";
Expand All @@ -57,7 +76,8 @@
echo "</table>\n<br>\n";
}
?>
<h2>Content breakdown by MIME type (First View)</h2>
<h3 class="hed_sub">Breakdown by MIME type</h3>
<h4>First View:</h4>
<?php
if ($isMultistep) {
$accordionHelper = new AccordionHtmlHelper($firstViewResults);
Expand All @@ -70,8 +90,8 @@
}
?>
<?php if ($repeatViewResults) { ?>
<br><hr><br>
<h2>Content breakdown by MIME type (Repeat View)</h2>

<h4>Repeat View:</h4>
<?php
if ($isMultistep) {
$accordionHelper = new AccordionHtmlHelper($repeatViewResults);
Expand All @@ -84,6 +104,9 @@
<?php } ?>
</div>
<?php include('footer.inc'); ?>
</div>
</div>
</div>

<!--Load the AJAX API-->
<script type="text/javascript" src="//www.google.com/jsapi"></script>
Expand Down
30 changes: 25 additions & 5 deletions www/breakdownTimeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
<html lang="en-us">
<head>
<title><?php echo $page_title; ?> - WebPageTest Content Breakdown</title>
<script>document.documentElement.classList.add('has-js');</script>

<?php $gaTemplate = 'Content Breakdown'; include ('head.inc'); ?>

</head>
<body>
<body class="result">
<?php
$tab = 'Test Result';
$subtab = 'Processing';
Expand Down Expand Up @@ -94,10 +96,26 @@
}
?>

<h2>Main-thread processing breakdown</h2>
<p>Where the browser's main thread was busy, not including idle time waiting for resources <?php
<div class="results_main_contain">
<div class="results_main">

<div class="results_and_command">

<div class="results_header">
<h2>Main-thread Processing</h2>
<p>Where the browser's main thread was busy, not including idle time waiting for resources <?php
echo " (<a href=\"/timeline/" . VER_TIMELINE . "timeline.php?test=$id&run=$run&cached=$cached\" title=\"View Chrome Dev Tools Timeline\">view timeline</a>)";
?>.</p>
</div>

<?php include("testinfo_command-bar.inc"); ?>

</div>

<div id="result" class="results_body">
<h3 class="hed_sub">Processing Breakdown</h3>



<div class="breakdownFrame">
<div class="breakdownFrame_item">
Expand All @@ -110,7 +128,8 @@
</div>
</div>

<h2>Main-thread time breakdown</h2>
<h3 class="hed_sub">Timing Breakdown</h3>

<p>All of the main-thread activity including idle (waiting for resources usually) <?php
echo " (<a href=\"/timeline/" . VER_TIMELINE . "timeline.php?test=$id&run=$run&cached=$cached\" title=\"View Chrome Dev Tools Timeline\">view timeline</a>)";
?>.</p>
Expand All @@ -126,12 +145,13 @@
<div class="table visualization_table" id="tableEventsIdle"></div>
</div>
</div>

</div>



</div>
<?php include('footer.inc'); ?>
</div></div></div>

<!--Load the AJAX API-->
<script type="text/javascript" src="//www.google.com/jsapi"></script>
Expand Down
11 changes: 8 additions & 3 deletions www/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

// Load composer-based dependencies
// Load models and composer-based dependencies
require_once(__DIR__ . '/../vendor/autoload.php');

// Load local deps
require_once(__DIR__ . '/common_lib.inc');
require_once(__DIR__ . '/plugins.php.inc');
require_once(__DIR__ . '/util.inc');
require_once(__DIR__ . '/models/user.php');

use WebPageTest\User;
use WebPageTest\RequestContext;

// Disable caching by default
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0", true);
Expand Down Expand Up @@ -137,7 +139,7 @@ if (!$privateInstall) {

// constants
define('VER_WEBPAGETEST', '21.07'); // webpagetest version
define('VER_CSS', 155); // version of the sitewide css file
define('VER_CSS', 161); // version of the sitewide css file
define('VER_JS', 40); // version of the sitewide javascript file
define('VER_JS_TEST', 47); // version of the javascript specific to the test pages
define('VER_JS_RUNNING', 1); // version of the javascript specific to the test running status page
Expand Down Expand Up @@ -388,3 +390,6 @@ if (array_key_exists('medianMetric', $_REQUEST)) {
if (is_file('./settings/custom_common.inc.php')) {
include('./settings/custom_common.inc.php');
}

// Create global request context for future use
$request = new RequestContext($_REQUEST);
43 changes: 25 additions & 18 deletions www/common_lib.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1137,12 +1137,8 @@ function GetScriptBlock() {
}
if ($show)
{
$html .= '<div class="script-block">';
$html .= '<p><a href="javascript:void(0)" id="script_in_results">Script <span class="arrow"></span></a></p>';
$html .= '<div id="script_in_results-container" class="hidden">';
$html .= 'Scripted Test:';
$html .= '<pre>' . htmlspecialchars($test['testinfo']['script']) . '</pre>';
$html .= '</div>';
$html .= '</div>';
}
}
return $html;
Expand All @@ -1160,37 +1156,44 @@ function GetTestInfoHtml($includeScript = true)
global $login;
global $admin;
global $privateInstall;
$html = '';
$html = '<ul>';
$run = null;
if (array_key_exists('run', $_REQUEST))
$run = intval($_REQUEST['run']);
if (isset($run) && isset($test) && is_array($test) && isset($test['testinfo']['test_runs'][$run]['tester']))
$html .= 'Tester: ' . $test['testinfo']['test_runs'][$run]['tester'] . '<br>';
$html .= '<li>Tester: ' . $test['testinfo']['test_runs'][$run]['tester'] . '</li>';
elseif (isset($test) && is_array($test) && isset($test['testinfo']['tester']) )
$html .= 'Tester: ' . $test['testinfo']['tester'] . '<br>';
$html .= '<li>Tester: ' . $test['testinfo']['tester'] . '</li>';
if( $dom )
$html .= 'DOM Element: <b>' . htmlspecialchars($dom) . '</b><br>';
$html .= '<li>DOM Element: ' . htmlspecialchars($dom) . '</li>';
if( $test['test']['fvonly'] )
$html .= '<b>First View only</b><br>';
$html .= '<li>First View only</li>';
if( isset($test['test']['runs']) )
$html .= 'Test runs: <b>' . $test['test']['runs'] . '</b><br>';
$html .= '<li>Test runs: ' . $test['test']['runs'] . '</li>';
if( isset($test['test']['authenticated']) && (int)$test['test']['authenticated'] == 1)
$html .= '<b>Authenticated: ' . htmlspecialchars($login) . '</b><br>';
$html .= '<li>Authenticated: ' . htmlspecialchars($login) . '</li>';
if (isset($test['testinfo']['addCmdLine']) && strlen($test['testinfo']['addCmdLine']))
$html .= '<b>Command Line: ' . htmlspecialchars($test['testinfo']['addCmdLine']) . '</b><br>';
$html .= '<li>Command Line: ' . htmlspecialchars($test['testinfo']['addCmdLine']) . '</li>';

if( isset($test['testinfo']['connectivity']) && !strcasecmp($test['testinfo']['connectivity'], 'custom') )
{
$html .= "<b>Connectivity:</b> {$test['testinfo']['bwIn']}/{$test['testinfo']['bwOut']} Kbps, {$test['testinfo']['latency']}ms Latency";
$html .= "<li>Connectivity: {$test['testinfo']['bwIn']}/{$test['testinfo']['bwOut']} Kbps, {$test['testinfo']['latency']}ms Latency";
if( $test['testinfo']['plr'] )
$html .= ", {$test['testinfo']['plr']}% Packet Loss";
if( $test['testinfo']['shaperLimit'] )
$html .= ", shaperLimit {$test['testinfo']['shaperLimit']}";
$html .= '<br>';
$html .= '</li>';
}
if( isset($test['testinfo']['script']) && strlen($test['testinfo']['script']) )
{
$html .= '<b>Scripted test</b><br>';
}
$html .= '<li>';
$html .= GetScriptBlock();
$html .= '</li>';
}
// TODO FIND CUSTOM METRICS HERE
if (array_key_exists('customMetrics', $test['testinfo']) && is_array($test['testinfo']['customMetrics']) && count($test['testinfo']['customMetrics']))
$html .= '<li><a href="/custom_metrics.php?' . "test=". $test['testinfo']['id'] ."&run=1&cached=0" . '">Custom Metrics</a></li>';
$html .= '</ul>';

return $html;
}
Expand Down Expand Up @@ -2573,7 +2576,11 @@ function formatMsInterval($val, $digits) {
if ($val == UNKNOWN_TIME)
return '-';

return number_format($val / 1000.0, $digits) . 's';
return removeLeadingZero(number_format($val / 1000.0, $digits) . '<span class="units">S</span>');
}

function removeLeadingZero($in){
return preg_replace('/^0*([^0]+)/i', '${1}', $in);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions www/cta-banner.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
//if not logged in, let's encourage sign-up
if( $supportsAuth && !defined('EMBED') )
{
if ($supportsSaml) {
if (!isset($USER_EMAIL) || !GetSetting('saml_account')) {
?>
<div class="cta-banner">
<p><strong>Save Test Results</strong> with a <strong>Free Account</strong>
<a class="btn-primary btn-primary-compact" href="https://app.webpagetest.org/ui/entry/wpt/signup?&utm_source=WPT_Test_Results&utm_content=button&utm_term=Sign_Up">Sign Up Now</a></p>
</div>
<?php
}
}
}


?>
Loading