Skip to content

Commit 62e1b77

Browse files
authored
Imply webgl2 within conformance2/ for getDefault3DContextVersion(). (#3725)
1 parent 24e7b2c commit 62e1b77

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

sdk/tests/js/webgl-test-utils.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ var getUrlOptions = (function() {
15811581
}
15821582
})();
15831583

1584-
var default3DContextVersion = 1;
1584+
var default3DContextVersion = null;
15851585

15861586
/**
15871587
* Set the default context version for create3DContext.
@@ -1598,7 +1598,26 @@ var setDefault3DContextVersion = function(version) {
15981598
* then look at the global default3DContextVersion variable.
15991599
*/
16001600
var getDefault3DContextVersion = function() {
1601-
return parseInt(getUrlOptions().webglVersion, 10) || default3DContextVersion;
1601+
const urlVersion = parseInt(getUrlOptions().webglVersion, 10);
1602+
if (urlVersion) return urlVersion;
1603+
1604+
if (!default3DContextVersion) {
1605+
const pathname = location.pathname;
1606+
const path_parts = pathname.split('/');
1607+
let in_conformance2_path = false;
1608+
while (path_parts.length) {
1609+
const part = path_parts.pop();
1610+
if (part.startsWith('conformance')) {
1611+
in_conformance2_path = (part == 'conformance2');
1612+
break;
1613+
}
1614+
}
1615+
// Found this first, so this must be a webgl2 test!
1616+
1617+
default3DContextVersion = in_conformance2_path ? 2 : 1;
1618+
console.warn(`getDefault3DContextVersion(): Implying webgl${default3DContextVersion} based on path.`);
1619+
}
1620+
return default3DContextVersion;
16021621
};
16031622

16041623
/**
@@ -1643,9 +1662,7 @@ var create3DContext = function(opt_canvas, opt_attributes, opt_version) {
16431662
}
16441663
}
16451664

1646-
if (!opt_version) {
1647-
opt_version = getDefault3DContextVersion();
1648-
}
1665+
opt_version = opt_version || getDefault3DContextVersion();
16491666
opt_canvas = opt_canvas || document.createElement("canvas");
16501667
if (typeof opt_canvas == 'string') {
16511668
opt_canvas = document.getElementById(opt_canvas);

0 commit comments

Comments
 (0)